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 ICanBoogie\OffsetNotDefined; |
||
16 | use Throwable; |
||
17 | |||
18 | /** |
||
19 | * Exception thrown in attempt to obtain a relation that is not defined. |
||
20 | * |
||
21 | * @property-read string $relation_name Name of the undefined relation. |
||
22 | * @property-read RelationCollection $collection Relation collection. |
||
23 | */ |
||
24 | class RelationNotDefined extends OffsetNotDefined implements Exception |
||
25 | { |
||
26 | /** |
||
27 | * @uses get_relation_name |
||
28 | * @uses get_collection |
||
29 | */ |
||
30 | use AccessorTrait; |
||
31 | |||
32 | /** |
||
33 | * Name of the undefined relation. |
||
34 | */ |
||
35 | private string $relation_name; |
||
36 | |||
37 | private function get_relation_name(): string |
||
0 ignored issues
–
show
|
|||
38 | { |
||
39 | return $this->relation_name; |
||
40 | } |
||
41 | |||
42 | private RelationCollection $collection; |
||
43 | |||
44 | private function get_collection(): RelationCollection |
||
0 ignored issues
–
show
|
|||
45 | { |
||
46 | return $this->collection; |
||
47 | } |
||
48 | |||
49 | public function __construct( |
||
50 | string $relation_name, |
||
51 | RelationCollection $collection, |
||
52 | Throwable $previous = null |
||
53 | ) { |
||
54 | $this->relation_name = $relation_name; |
||
0 ignored issues
–
show
|
|||
55 | $this->collection = $collection; |
||
0 ignored issues
–
show
|
|||
56 | |||
57 | parent::__construct([ $relation_name, $collection ], $previous); |
||
58 | } |
||
59 | } |
||
60 |
This check looks for private methods that have been defined, but are not used inside the class.