Test Failed
Push — master ( dbe410...b8c007 )
by Kirill
02:19
created

ProxyDictionary::getParentDictionary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Dictionary;
11
12
use Railt\Reflection\Contracts\Definition;
13
use Railt\Reflection\Contracts\Definition\TypeDefinition;
14
use Railt\Reflection\Contracts\Dictionary;
15
use Railt\Reflection\Contracts\Type;
16
17
/**
18
 * Class ProxyDictionary
19
 */
20
class ProxyDictionary implements Dictionary
21
{
22
    /**
23
     * @var Dictionary
24
     */
25
    private $parent;
26
27
    /**
28
     * ProxyDictionary constructor.
29
     * @param Dictionary $parent
30
     */
31 9
    public function __construct(Dictionary $parent)
32
    {
33 9
        $this->parent = $parent;
34 9
    }
35
36
    /**
37
     * @return Dictionary
38
     */
39
    public function getParentDictionary(): Dictionary
40
    {
41
        return $this->parent;
42
    }
43
44
    /**
45
     * @param Type|null $of
46
     * @return iterable|TypeDefinition[]
47
     */
48 3
    public function all(Type $of = null): iterable
49
    {
50 3
        foreach ($this->parent->all($of) as $definition) {
51 3
            yield $definition;
52
        }
53 3
    }
54
55
    /**
56
     * @param string $name
57
     * @return bool
58
     */
59 3
    public function has(string $name): bool
60
    {
61 3
        return $this->parent->has($name);
62
    }
63
64
    /**
65
     * @param string $name
66
     * @return null|TypeDefinition
67
     */
68 11
    public function find(string $name): ?TypeDefinition
69
    {
70 11
        return $this->parent->find($name);
71
    }
72
73
    /**
74
     * @param string $name
75
     * @param Definition|null $from
76
     * @return TypeDefinition
77
     * @throws \Railt\Reflection\Exception\TypeNotFoundException
78
     */
79 17
    public function get(string $name, Definition $from = null): TypeDefinition
80
    {
81 17
        return $this->parent->get($name, $from);
82
    }
83
84
    /**
85
     * @param TypeDefinition $type
86
     * @return Dictionary
87
     */
88 17
    public function add(TypeDefinition $type): Dictionary
89
    {
90 17
        return $this->parent->add($type);
91
    }
92
}
93