Total Complexity | 10 |
Total Lines | 105 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
14 | class Search |
||
15 | { |
||
16 | /** |
||
17 | * @var Coin[] |
||
18 | */ |
||
19 | private $currencies = []; |
||
20 | |||
21 | /** |
||
22 | * @var Exchange[] |
||
23 | */ |
||
24 | private $exchanges = []; |
||
25 | |||
26 | /** |
||
27 | * @var Ico[] |
||
28 | */ |
||
29 | private $icos = []; |
||
30 | |||
31 | /** |
||
32 | * @var Person[] |
||
33 | */ |
||
34 | private $people = []; |
||
35 | |||
36 | /** |
||
37 | * @var Tag[] |
||
38 | */ |
||
39 | private $tags = []; |
||
40 | |||
41 | /** |
||
42 | * @return Coin[] |
||
43 | */ |
||
44 | 2 | public function getCurrencies(): array |
|
45 | { |
||
46 | 2 | return $this->currencies; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param Coin[] $currencies |
||
51 | */ |
||
52 | 1 | public function setCurrencies(array $currencies): void |
|
55 | 1 | } |
|
56 | |||
57 | /** |
||
58 | * @return Exchange[] |
||
59 | */ |
||
60 | 1 | public function getExchanges(): array |
|
61 | { |
||
62 | 1 | return $this->exchanges; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param Exchange[] $exchanges |
||
67 | */ |
||
68 | 1 | public function setExchanges(array $exchanges): void |
|
69 | { |
||
70 | 1 | $this->exchanges = $exchanges; |
|
71 | 1 | } |
|
72 | |||
73 | /** |
||
74 | * @return Ico[] |
||
75 | */ |
||
76 | 2 | public function getIcos(): array |
|
77 | { |
||
78 | 2 | return $this->icos; |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param Ico[] $icos |
||
83 | */ |
||
84 | 1 | public function setIcos(array $icos): void |
|
85 | { |
||
86 | 1 | $this->icos = $icos; |
|
87 | 1 | } |
|
88 | |||
89 | /** |
||
90 | * @return Person[] |
||
91 | */ |
||
92 | 3 | public function getPeople(): array |
|
93 | { |
||
94 | 3 | return $this->people; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param Person[] $people |
||
99 | */ |
||
100 | 3 | public function setPeople(array $people): void |
|
101 | { |
||
102 | 3 | $this->people = $people; |
|
103 | 3 | } |
|
104 | |||
105 | /** |
||
106 | * @return Tag[] |
||
107 | */ |
||
108 | 2 | public function getTags(): array |
|
111 | } |
||
112 | |||
113 | /** |
||
114 | * @param Tag[] $tags |
||
115 | */ |
||
116 | 2 | public function setTags(array $tags): void |
|
119 | 2 | } |
|
120 | } |
||
121 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: