Total Complexity | 6 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class RelationMap implements \IteratorAggregate |
||
16 | { |
||
17 | /** @var Relation[] */ |
||
18 | private $fields = []; |
||
19 | |||
20 | /** |
||
21 | * @param string $name |
||
22 | * @return bool |
||
23 | */ |
||
24 | public function has(string $name): bool |
||
25 | { |
||
26 | return isset($this->fields[$name]); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $name |
||
31 | * @return Relation |
||
32 | */ |
||
33 | public function get(string $name): Relation |
||
34 | { |
||
35 | if (!$this->has($name)) { |
||
36 | throw new RelationException("Undefined relation `{$name}`"); |
||
37 | } |
||
38 | |||
39 | return $this->fields[$name]; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param string $name |
||
44 | * @param Relation $relation |
||
45 | * @return RelationMap |
||
46 | */ |
||
47 | public function set(string $name, Relation $relation): self |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return Relation[]|\Traversable |
||
60 | */ |
||
61 | public function getIterator() |
||
64 | } |
||
65 | } |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: