| Total Complexity | 5 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 83.33% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 13 | final class ServerFactory |
||
| 14 | { |
||
| 15 | private $clock; |
||
| 16 | |||
| 17 | 3 | public function __construct(Clock $clock) |
|
| 18 | { |
||
| 19 | 3 | $this->clock = $clock; |
|
| 20 | 3 | } |
|
| 21 | |||
| 22 | 3 | public function __invoke(): Server |
|
| 23 | { |
||
| 24 | 3 | switch (\PHP_OS) { |
|
| 25 | 3 | case 'Darwin': |
|
| 26 | return new OSX($this->clock); |
||
| 27 | |||
| 28 | 3 | case 'Linux': |
|
| 29 | 3 | return new Linux($this->clock); |
|
| 30 | } |
||
| 31 | |||
| 32 | throw new UnsupportedOperatingSystem; |
||
| 33 | } |
||
| 34 | |||
| 35 | 3 | public static function build(Clock $clock): Server |
|
| 38 | } |
||
| 39 | } |
||
| 40 |