Total Complexity | 9 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | class Subscription implements SubscriptionInterface |
||
17 | { |
||
18 | /** @var int|null */ |
||
19 | protected $id; |
||
20 | |||
21 | /** @var OrderInterface */ |
||
22 | protected $order; |
||
23 | |||
24 | /** @var string|null */ |
||
25 | protected $subscriptionId; |
||
26 | |||
27 | /** @var string|null */ |
||
28 | protected $customerId; |
||
29 | |||
30 | /** @var string */ |
||
31 | protected $state = SubscriptionInterface::STATE_NEW; |
||
32 | |||
33 | public function getId(): ?int |
||
34 | { |
||
35 | return $this->id; |
||
36 | } |
||
37 | |||
38 | public function getOrder(): OrderInterface |
||
39 | { |
||
40 | return $this->order; |
||
41 | } |
||
42 | |||
43 | public function setOrder(OrderInterface $order): void |
||
44 | { |
||
45 | $this->order = $order; |
||
46 | } |
||
47 | |||
48 | public function getSubscriptionId(): ?string |
||
49 | { |
||
50 | return $this->subscriptionId; |
||
51 | } |
||
52 | |||
53 | public function setSubscriptionId(?string $subscriptionId): void |
||
54 | { |
||
55 | $this->subscriptionId = $subscriptionId; |
||
56 | } |
||
57 | |||
58 | public function getState(): string |
||
59 | { |
||
60 | return $this->state; |
||
61 | } |
||
62 | |||
63 | public function setState(string $state): void |
||
66 | } |
||
67 | |||
68 | public function getCustomerId(): ?string |
||
69 | { |
||
70 | return $this->customerId; |
||
71 | } |
||
72 | |||
73 | public function setCustomerId(?string $customerId): void |
||
76 | } |
||
77 | } |
||
78 |
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: