| Total Complexity | 8 |
| Total Lines | 74 |
| Duplicated Lines | 0 % |
| Coverage | 90% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class CalendarEvent extends BaseEvent |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var DateTimeInterface |
||
| 20 | */ |
||
| 21 | protected $start; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var DateTimeInterface |
||
| 25 | */ |
||
| 26 | protected $end; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var array |
||
| 30 | */ |
||
| 31 | protected $filters; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var Event[] |
||
| 35 | */ |
||
| 36 | protected $events = []; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var string|null |
||
| 40 | */ |
||
| 41 | private $timezone; |
||
| 42 | |||
| 43 | 4 | public function __construct( |
|
| 53 | 4 | } |
|
| 54 | |||
| 55 | 1 | public function getStart(): DateTimeInterface |
|
| 56 | { |
||
| 57 | 1 | return $this->start; |
|
| 58 | } |
||
| 59 | |||
| 60 | 1 | public function getEnd(): DateTimeInterface |
|
| 61 | { |
||
| 62 | 1 | return $this->end; |
|
| 63 | } |
||
| 64 | |||
| 65 | 1 | public function getFilters(): array |
|
| 66 | { |
||
| 67 | 1 | return $this->filters; |
|
| 68 | } |
||
| 69 | |||
| 70 | 1 | public function addEvent(Event $event): self |
|
| 71 | { |
||
| 72 | 1 | if (!\in_array($event, $this->events, true)) { |
|
| 73 | 1 | $this->events[] = $event; |
|
| 74 | } |
||
| 75 | |||
| 76 | 1 | return $this; |
|
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @return Event[] |
||
| 81 | */ |
||
| 82 | 1 | public function getEvents(): array |
|
| 85 | } |
||
| 86 | |||
| 87 | public function getTimezone(): ?string |
||
| 88 | { |
||
| 90 | } |
||
| 91 | } |
||
| 92 |
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: