| Total Complexity | 1 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class PushNotification |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | public $title; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | public $message; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * User Object |
||
| 23 | * |
||
| 24 | * @var Users |
||
| 25 | */ |
||
| 26 | public $to; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Additional params if needed |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | public $params; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Init a push notification object |
||
| 37 | * |
||
| 38 | * @param Users $user |
||
| 39 | * @param string $title |
||
| 40 | * @param string $message |
||
| 41 | * @param array $params |
||
| 42 | * |
||
| 43 | * @return void |
||
| 44 | */ |
||
| 45 | public function __construct(Users $user, string $title, string $message, ?array $params = null) |
||
| 53 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: