Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
Schedule
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
8 / 8
16
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConference
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDays
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRooms
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
 getStartDateTime
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
4
 getEndDateTime
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
4
 getGenerator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Helpers\Schedule;
6
7use Carbon\Carbon;
8
9class 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    public function getRooms(): array
44    {
45        $rooms = [];
46        foreach ($this->days as $day) {
47            foreach ($day->getRooms() as $room) {
48                $name = $room->getName();
49                $rooms[$name] = $room;
50            }
51        }
52
53        return $rooms;
54    }
55
56
57    public function getStartDateTime(): ?Carbon
58    {
59        $start = null;
60        foreach ($this->days as $day) {
61            $time = $day->getStart();
62            if ($time > $start && $start) {
63                continue;
64            }
65
66            $start = $time;
67        }
68
69        return $start;
70    }
71
72    public function getEndDateTime(): ?Carbon
73    {
74        $end = null;
75        foreach ($this->days as $day) {
76            $time = $day->getEnd();
77            if ($time < $end && $end) {
78                continue;
79            }
80
81            $end = $time;
82        }
83
84        return $end;
85    }
86
87    public function getGenerator(): ?ScheduleGenerator
88    {
89        return $this->generator;
90    }
91}