1 | <?php |
||
12 | class Mautic |
||
13 | { |
||
14 | /** |
||
15 | * Mautic base (root) URL |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $baseUrl; |
||
20 | |||
21 | /** |
||
22 | * Mautic Contact |
||
23 | * |
||
24 | * @var Contact |
||
25 | */ |
||
26 | protected $contact; |
||
27 | |||
28 | /** |
||
29 | * Mautic Contact Cookie |
||
30 | * |
||
31 | * @var Cookie |
||
32 | */ |
||
33 | protected $cookie; |
||
34 | |||
35 | /** |
||
36 | * Constructor |
||
37 | * |
||
38 | * @param string $baseUrl |
||
39 | */ |
||
40 | 26 | public function __construct($baseUrl) |
|
46 | |||
47 | /** |
||
48 | * Returns Mautic's base URL |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 6 | public function getBaseUrl() |
|
56 | |||
57 | /** |
||
58 | * Returns new Mautic Form representation object |
||
59 | * |
||
60 | * @param int $id |
||
61 | * |
||
62 | * @return Form |
||
63 | */ |
||
64 | 10 | public function getForm($id) |
|
68 | |||
69 | /** |
||
70 | * Sets the Mautic Contact if you want to replace the default one |
||
71 | * |
||
72 | * @param Contact $contact |
||
73 | * |
||
74 | * @return Mautic |
||
75 | */ |
||
76 | 2 | public function setContact(Contact $contact) |
|
82 | |||
83 | /** |
||
84 | * Returns Mautic Contact representation object |
||
85 | * |
||
86 | * @return Contact |
||
87 | */ |
||
88 | 12 | public function getContact() |
|
92 | |||
93 | /** |
||
94 | * Returns Mautic Cookie representation object |
||
95 | * |
||
96 | * @return Cookie |
||
97 | */ |
||
98 | public function getCookie() |
||
102 | } |
||
103 |
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: