diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2019-11-27 23:43:21 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2019-12-08 02:20:48 +0100 |
commit | 42721e95726559b4a601240bb5b0fe4e5d755b2a (patch) | |
tree | 6810e05f845ca787acc1d02fa82d3df15cd0ef9b /src/Helpers/Schedule/Schedule.php | |
parent | 377b390c97afb9106fd9a139819d00306f996f24 (diff) |
Added Schedule parsing and replaced old Fahrplan importer
Resolves #553 (Change Frab Import from xCal to XML)
Resolves #538 (Feature Request: Multi Frab Import)
Diffstat (limited to 'src/Helpers/Schedule/Schedule.php')
-rw-r--r-- | src/Helpers/Schedule/Schedule.php | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/Helpers/Schedule/Schedule.php b/src/Helpers/Schedule/Schedule.php new file mode 100644 index 00000000..7150480c --- /dev/null +++ b/src/Helpers/Schedule/Schedule.php @@ -0,0 +1,111 @@ +<?php + +declare(strict_types=1); + +namespace Engelsystem\Helpers\Schedule; + +use Carbon\Carbon; + +class Schedule +{ + /** @var string */ + protected $version; + + /** @var Conference */ + protected $conference; + + /** @var Day[] */ + protected $day; + + /** + * @param string $version + * @param Conference $conference + * @param Day[] $days + */ + public function __construct( + string $version, + Conference $conference, + array $days + ) { + $this->version = $version; + $this->conference = $conference; + $this->day = $days; + } + + /** + * @return string + */ + public function getVersion(): string + { + return $this->version; + } + + /** + * @return Conference + */ + public function getConference(): Conference + { + return $this->conference; + } + + /** + * @return Day[] + */ + public function getDay(): array + { + return $this->day; + } + + /** + * @return Room[] + */ + public function getRooms(): array + { + $rooms = []; + foreach ($this->day as $day) { + foreach ($day->getRoom() as $room) { + $name = $room->getName(); + $rooms[$name] = $room; + } + } + + return $rooms; + } + + + /** + * @return Carbon|null + */ + public function getStartDateTime(): ?Carbon + { + $start = null; + foreach ($this->day as $day) { + $time = $day->getStart(); + if ($time > $start && $start) { + continue; + } + + $start = $time; + } + + return $start; + } + + /** + * @return Carbon|null + */ + public function getEndDateTime(): ?Carbon + { + $end = null; + foreach ($this->day as $day) { + $time = $day->getEnd(); + if ($time < $end && $end) { + continue; + } + + $end = $time; + } + + return $end; + } +} |