Lines
100.00%
4 / 4
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| TriggerFactory | 100.00% | 4 / 4 | 100.00% | 2 / 2 | 3 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| createTriggerFor | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Schedule; | |
| 6 | ||
| 7 | use Stewart\Contracts\Time\Clock; | |
| 8 | use Stewart\Support\Schedule\ElapsedSchedule; | |
| 9 | use Stewart\Support\Schedule\WallClockSchedule; | |
| 10 | ||
| 11 | final readonly class TriggerFactory | |
| 12 | { | |
| 13 | public function __construct(private Clock $clock) {} | |
| 14 | ||
| 15 | public function createTriggerFor(WallClockSchedule|ElapsedSchedule $schedule): Trigger | |
| 16 | { | |
| 17 | return $schedule instanceof ElapsedSchedule | |
| 18 | ? new ElapsedTrigger($schedule, $this->clock) | |
| 19 | : new WallTrigger($schedule, $this->clock); | |
| 20 | } | |
| 21 | } |