1: <?php
2: declare(strict_types=1);
3:
4: namespace om\ICal\Value;
5:
6: use DateInterval;
7: use Stringable;
8:
9: /**
10: * PERIOD value (RFC 5545, section 3.3.9): start and end, or start and duration.
11: */
12: final readonly class Period implements Stringable {
13: public function __construct(
14: public DateTimeValue $start,
15: public DateTimeValue $end,
16: public ?DateInterval $duration = null,
17: ) {
18: }
19:
20: public function __toString(): string {
21: return $this->start . '/' . ($this->duration !== null ? Duration::format($this->duration) : $this->end);
22: }
23: }
24: