1 | <?php |
||
2 | |||
3 | namespace Coinpaprika\Model; |
||
4 | |||
5 | use Coinpaprika\Model\Coin; |
||
6 | use Coinpaprika\Model\Exchange; |
||
7 | use Coinpaprika\Model\Search\Ico; |
||
0 ignored issues
–
show
|
|||
8 | use Coinpaprika\Model\Person; |
||
9 | use Coinpaprika\Model\Tag; |
||
10 | |||
11 | /** |
||
12 | * Class Search |
||
13 | * |
||
14 | * @package \Coinpaprika\Model |
||
15 | * |
||
16 | * @author Krzysztof Przybyszewski <[email protected]> |
||
17 | */ |
||
18 | class Search |
||
19 | { |
||
20 | /** |
||
21 | * @var Coin[] |
||
22 | */ |
||
23 | private $currencies = []; |
||
24 | |||
25 | /** |
||
26 | * @var Exchange[] |
||
27 | */ |
||
28 | private $exchanges = []; |
||
29 | |||
30 | /** |
||
31 | * @var Ico[] |
||
32 | */ |
||
33 | private $icos = []; |
||
34 | |||
35 | /** |
||
36 | * @var Person[] |
||
37 | */ |
||
38 | private $people = []; |
||
39 | |||
40 | /** |
||
41 | * @var Tag[] |
||
42 | */ |
||
43 | private $tags = []; |
||
44 | |||
45 | /** |
||
46 | * @return Coin[] |
||
47 | */ |
||
48 | 2 | public function getCurrencies(): array |
|
49 | { |
||
50 | 2 | return $this->currencies; |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * @param Coin[] $currencies |
||
55 | */ |
||
56 | 1 | public function setCurrencies(array $currencies): void |
|
57 | { |
||
58 | 1 | $this->currencies = $currencies; |
|
59 | 1 | } |
|
60 | |||
61 | /** |
||
62 | * @return Exchange[] |
||
63 | */ |
||
64 | 1 | public function getExchanges(): array |
|
65 | { |
||
66 | 1 | return $this->exchanges; |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param Exchange[] $exchanges |
||
71 | */ |
||
72 | 1 | public function setExchanges(array $exchanges): void |
|
73 | { |
||
74 | 1 | $this->exchanges = $exchanges; |
|
75 | 1 | } |
|
76 | |||
77 | /** |
||
78 | * @return Ico[] |
||
79 | */ |
||
80 | 2 | public function getIcos(): array |
|
81 | { |
||
82 | 2 | return $this->icos; |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * @param Ico[] $icos |
||
87 | */ |
||
88 | 1 | public function setIcos(array $icos): void |
|
89 | { |
||
90 | 1 | $this->icos = $icos; |
|
91 | 1 | } |
|
92 | |||
93 | /** |
||
94 | * @return Person[] |
||
95 | */ |
||
96 | 3 | public function getPeople(): array |
|
97 | { |
||
98 | 3 | return $this->people; |
|
99 | } |
||
100 | |||
101 | /** |
||
102 | * @param Person[] $people |
||
103 | */ |
||
104 | 3 | public function setPeople(array $people): void |
|
105 | { |
||
106 | 3 | $this->people = $people; |
|
107 | 3 | } |
|
108 | |||
109 | /** |
||
110 | * @return Tag[] |
||
111 | */ |
||
112 | 2 | public function getTags(): array |
|
113 | { |
||
114 | 2 | return $this->tags; |
|
115 | } |
||
116 | |||
117 | /** |
||
118 | * @param Tag[] $tags |
||
119 | */ |
||
120 | 2 | public function setTags(array $tags): void |
|
121 | { |
||
122 | 2 | $this->tags = $tags; |
|
123 | 2 | } |
|
124 | } |
||
125 |
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: