1 | <?php namespace C4tech\RayEmitter\Domain; |
||
6 | abstract class ValueObjectCollection extends Collection implements ValueObject |
||
7 | { |
||
8 | /** |
||
9 | * Collection Class |
||
10 | * |
||
11 | * Class name of member Value Objects |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $collectionClass = ''; |
||
15 | |||
16 | /** |
||
17 | * @inheritDoc |
||
18 | */ |
||
19 | public function equals(ValueObject $other) |
||
31 | |||
32 | /** |
||
33 | * Get Hash |
||
34 | * |
||
35 | * Calculate an md5 sum of the collection. |
||
36 | * @return string |
||
37 | */ |
||
38 | public function getHash() |
||
42 | |||
43 | /** |
||
44 | * @inheritDoc |
||
45 | */ |
||
46 | public function getValue() |
||
50 | |||
51 | /** |
||
52 | * @inheritDoc |
||
53 | */ |
||
54 | public static function jsonSerialize() |
||
61 | |||
62 | /** |
||
63 | * @inheritDoc |
||
64 | */ |
||
65 | public static function jsonUnserialize($data) |
||
78 | |||
79 | /** |
||
80 | * Sort By Value |
||
81 | * |
||
82 | * Sort the array by the VO's value. |
||
83 | * @return static |
||
84 | */ |
||
85 | public function sortByValue() |
||
91 | } |
||
92 |
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: