for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace backend\observers;
use yii\base\ModelEvent;
use yii\db\AfterSaveEvent;
use backend\models\Log;
use yii\db\ActiveRecord;
class LogObserver
{
public function observeCreate(AfterSaveEvent $event)
Log::find()
->createLogEntity(
self::getEntity($event),
backend\observers\LogObserver::getEntity()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
self::/** @scrutinizer ignore-call */
getEntity($event),
Log::ACTION_CREATE,
false,
true
)->save();
}
public function observeUpdate(ModelEvent $event)
Log::ACTION_UPDATE
public function observeDelete(ModelEvent $event)
Log::ACTION_DELETE,
true,
false
/**
* @param $event
* @return ActiveRecord
*/
protected function getEntity($event)
return $event->sender;