Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
29 / 29 |
|
100.00% |
9 / 9 |
CRAP | |
100.00% |
1 / 1 |
Schedule | |
100.00% |
29 / 29 |
|
100.00% |
9 / 9 |
18 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getVersion | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getConference | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDays | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAllRooms | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
getRooms | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
getStartDateTime | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
getEndDateTime | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
getGenerator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Engelsystem\Helpers\Schedule; |
6 | |
7 | use Carbon\Carbon; |
8 | |
9 | class Schedule extends ScheduleData |
10 | { |
11 | /** |
12 | * @param Day[] $days |
13 | */ |
14 | public function __construct( |
15 | protected string $version, |
16 | protected Conference $conference, |
17 | protected array $days, |
18 | protected ?ScheduleGenerator $generator = null, |
19 | ) { |
20 | } |
21 | |
22 | public function getVersion(): string |
23 | { |
24 | return $this->version; |
25 | } |
26 | |
27 | public function getConference(): Conference |
28 | { |
29 | return $this->conference; |
30 | } |
31 | |
32 | /** |
33 | * @return Day[] |
34 | */ |
35 | public function getDays(): array |
36 | { |
37 | return $this->days; |
38 | } |
39 | |
40 | /** |
41 | * @return Room[] |
42 | * |
43 | * Returns a list of all rooms for all days |
44 | */ |
45 | public function getAllRooms(): array |
46 | { |
47 | $rooms = []; |
48 | foreach ($this->days as $day) { |
49 | foreach ($day->getRooms() as $room) { |
50 | $rooms[] = $room; |
51 | } |
52 | } |
53 | |
54 | return $rooms; |
55 | } |
56 | |
57 | /** |
58 | * @return Room[] |
59 | * |
60 | * Returns a list of rooms unique by name and thus the instance of the last day they are used |
61 | */ |
62 | public function getRooms(): array |
63 | { |
64 | $rooms = []; |
65 | foreach ($this->getAllRooms() as $room) { |
66 | $name = $room->getName(); |
67 | $rooms[$name] = $room; |
68 | } |
69 | |
70 | return $rooms; |
71 | } |
72 | |
73 | public function getStartDateTime(): ?Carbon |
74 | { |
75 | $start = null; |
76 | foreach ($this->days as $day) { |
77 | $time = $day->getStart(); |
78 | if ($time > $start && $start) { |
79 | continue; |
80 | } |
81 | |
82 | $start = $time; |
83 | } |
84 | |
85 | return $start; |
86 | } |
87 | |
88 | public function getEndDateTime(): ?Carbon |
89 | { |
90 | $end = null; |
91 | foreach ($this->days as $day) { |
92 | $time = $day->getEnd(); |
93 | if ($time < $end && $end) { |
94 | continue; |
95 | } |
96 | |
97 | $end = $time; |
98 | } |
99 | |
100 | return $end; |
101 | } |
102 | |
103 | public function getGenerator(): ?ScheduleGenerator |
104 | { |
105 | return $this->generator; |
106 | } |
107 | } |