1 | <?php |
||
12 | final class DomainMessage implements DomainMessageInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | private $playHead; |
||
18 | |||
19 | /** |
||
20 | * @var Metadata |
||
21 | */ |
||
22 | private $metadata; |
||
23 | |||
24 | /** |
||
25 | * @var mixed |
||
26 | */ |
||
27 | private $payload; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $id; |
||
33 | |||
34 | /** |
||
35 | * @var DateTime |
||
36 | */ |
||
37 | private $recordedOn; |
||
38 | |||
39 | /** |
||
40 | * @param string $id |
||
41 | * @param int $playHead |
||
42 | * @param Metadata $metadata |
||
43 | * @param mixed $payload |
||
44 | * @param DateTime $recordedOn |
||
45 | 33 | */ |
|
46 | public function __construct($id, $playHead, Metadata $metadata, $payload, DateTime $recordedOn) |
||
54 | |||
55 | /** |
||
56 | * @param string $id |
||
57 | * @param int $playHead |
||
58 | * @param Metadata $metadata |
||
59 | * @param mixed $payload |
||
60 | * |
||
61 | * @return DomainMessage |
||
62 | 21 | */ |
|
63 | public static function recordNow($id, $playHead, Metadata $metadata, $payload) |
||
67 | |||
68 | /** |
||
69 | * @return int |
||
70 | 6 | */ |
|
71 | public function getPlayHead() |
||
75 | |||
76 | /** |
||
77 | * @return Metadata |
||
78 | 6 | */ |
|
79 | public function getMetadata() |
||
83 | |||
84 | /** |
||
85 | * @return mixed |
||
86 | 12 | */ |
|
87 | public function getPayload() |
||
91 | |||
92 | /** |
||
93 | * @return string |
||
94 | 6 | */ |
|
95 | public function getId() |
||
99 | |||
100 | /** |
||
101 | * @return DateTime |
||
102 | 6 | */ |
|
103 | public function getRecordedOn() |
||
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | 6 | */ |
|
111 | public function getType() |
||
115 | } |
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: