for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* NOTICE OF LICENSE
*
* Part of the Rinvex Repository Package.
* This source file is subject to The MIT License (MIT)
* that is bundled with this package in the LICENSE file.
* Package: Rinvex Repository Package
* License: The MIT License (MIT)
* Link: https://rinvex.com
*/
namespace Rinvex\Repository\Exceptions;
use RuntimeException;
class EntityNotFoundException extends RuntimeException
{
/**
* Id of the affected model.
* @var string
protected $id;
* Name of the affected model.
protected $model;
* Set the affected model.
* @param string $model
* @param int $id
* @return void
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
public function __construct($model, $id)
$this->id = $id;
$id
string
integer
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;
$this->model = $model;
$this->message = "No results for model [{$model}] #{$id}.";
sprintf
$model
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.
// Instead of $x = "foo $bar $baz"; // Better use either $x = "foo " . $bar . " " . $baz; $x = sprintf("foo %s %s", $bar, $baz);
}
* Get the affected model.
* @return string
public function getModel()
return $this->model;
* Get the affected model Id.
public function getId()
return $this->id;
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.