Lines
100.00%
5 / 5
Functions and Methods
100.00%
5 / 5
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| OneShotSchedule | 100.00% | 5 / 5 | 100.00% | 5 / 5 | 6 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| fromMoment | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| findNextOccurrenceAfter | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| describe | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| isRecurring | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Support\Schedule; | |
| 6 | ||
| 7 | use DateTimeImmutable; | |
| 8 | ||
| 9 | /** @internal */ | |
| 10 | final readonly class OneShotSchedule implements WallClockSchedule | |
| 11 | { | |
| 12 | private function __construct(public DateTimeImmutable $moment) {} | |
| 13 | ||
| 14 | public static function fromMoment(DateTimeImmutable $moment): self | |
| 15 | { | |
| 16 | return new self($moment); | |
| 17 | } | |
| 18 | ||
| 19 | public function findNextOccurrenceAfter(DateTimeImmutable $after): ?DateTimeImmutable | |
| 20 | { | |
| 21 | return $this->moment > $after ? $this->moment->setTimezone($after->getTimezone()) : null; | |
| 22 | } | |
| 23 | ||
| 24 | public function describe(): string | |
| 25 | { | |
| 26 | return \sprintf('once at %s', $this->moment->format('c')); | |
| 27 | } | |
| 28 | ||
| 29 | public function isRecurring(): bool | |
| 30 | { | |
| 31 | return false; | |
| 32 | } | |
| 33 | } |