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 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| WorkerSunCalendarFactory | 100.00% | 4 / 4 | 100.00% | 2 / 2 | 3 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| createSunCalendar | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Worker; | |
| 6 | ||
| 7 | use Stewart\Contracts\Sun\SunCalendar; | |
| 8 | use Stewart\Contracts\Time\Clock; | |
| 9 | use Stewart\Runtime\Ipc\Message\Bootstrap; | |
| 10 | use Stewart\Sun\LocatedSunCalendar; | |
| 11 | use Stewart\Sun\NoaaSolarCalculator; | |
| 12 | use Stewart\Sun\UnlocatedSunCalendar; | |
| 13 | ||
| 14 | final readonly class WorkerSunCalendarFactory | |
| 15 | { | |
| 16 | public function __construct( | |
| 17 | private Bootstrap $bootstrap, | |
| 18 | private Clock $clock, | |
| 19 | private NoaaSolarCalculator $calculator, | |
| 20 | ) {} | |
| 21 | ||
| 22 | public function createSunCalendar(): SunCalendar | |
| 23 | { | |
| 24 | if ($this->bootstrap->location === null) { | |
| 25 | return new UnlocatedSunCalendar(); | |
| 26 | } | |
| 27 | ||
| 28 | return new LocatedSunCalendar($this->bootstrap->location, $this->clock, $this->calculator); | |
| 29 | } | |
| 30 | } |