1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the ICanBoogie package. |
||
5 | * |
||
6 | * (c) Olivier Laviale <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace ICanBoogie\ActiveRecord; |
||
13 | |||
14 | use ICanBoogie\Accessor\AccessorTrait; |
||
15 | use LogicException; |
||
16 | use Throwable; |
||
17 | |||
18 | /** |
||
19 | * Exception thrown in attempt to obtain a model that is not defined. |
||
20 | * |
||
21 | * @property-read string $id The identifier of the model. |
||
22 | */ |
||
23 | class ModelNotDefined extends LogicException implements Exception |
||
24 | { |
||
25 | /** |
||
26 | * @uses get_id |
||
27 | */ |
||
28 | use AccessorTrait; |
||
29 | |||
30 | private function get_id(): string |
||
0 ignored issues
–
show
|
|||
31 | { |
||
32 | return $this->id; |
||
33 | } |
||
34 | |||
35 | public function __construct( |
||
36 | private string $id, |
||
37 | Throwable $previous = null |
||
38 | ) { |
||
39 | parent::__construct($this->format_message($id), 0, $previous); |
||
40 | } |
||
41 | |||
42 | private function format_message(string $id): string |
||
43 | { |
||
44 | return "Model not defined: $id."; |
||
45 | } |
||
46 | } |
||
47 |
This check looks for private methods that have been defined, but are not used inside the class.