for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Apps\Model\Front\Profile;
use Apps\ActiveRecord\UserNotification;
use Ffcms\Core\Arch\Model;
/**
* Class EntityAddNotification. Add user notification in database table
* @package Apps\Model\Front\Profile
*/
class EntityAddNotification extends Model
{
const MSG_DEFAULT = 'New notification event: «%snippet%»';
const MSG_ADD_WALLPOST = 'New post on the wall: «%snippet%»';
const MSG_ADD_WALLANSWER = 'New answer «%snippet%» for wall post «%post%»';
const MSG_ADD_COMMENTANSWER = 'New answer «%snippet%» to your comment «%post%»';
const MSG_ADD_FEEDBACKANSWER = 'New answer «%snippet%» to your feedback request «%post%»';
private $_targetId;
* EntityAddNotification constructor. Pass target user_id inside the model
* @param bool $targetId
public function __construct($targetId)
$this->_targetId = $targetId;
parent::__construct();
}
* Add notification for user
* @param string $uri
* @param string $msg
* @param array|null $vars
public function add($uri, $msg = self::MSG_DEFAULT, array $vars = null)
// save data into database
$record = new UserNotification();
$record->user_id = $this->_targetId;
$user_id
integer
$this->_targetId
boolean
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
$record->uri = $uri;
$record->msg = $msg;
if ($vars !== null) {
$record->vars = $vars;
$record->save();
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.