Passed
Push — 6.0 ( 7ab78c...8e0f01 )
by Olivier
01:35
created

lib/ActiveRecord/RelationNotDefined.php (4 issues)

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
The method get_relation_name() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
38
    {
39
        return $this->relation_name;
40
    }
41
42
    private RelationCollection $collection;
43
44
    private function get_collection(): RelationCollection
0 ignored issues
show
The method get_collection() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
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
The property relation_name is declared read-only in ICanBoogie\ActiveRecord\RelationNotDefined.
Loading history...
55
        $this->collection = $collection;
0 ignored issues
show
The property collection is declared read-only in ICanBoogie\ActiveRecord\RelationNotDefined.
Loading history...
56
57
        parent::__construct([ $relation_name, $collection ], $previous);
58
    }
59
}
60