Lines
0.00%
0 / 13
Functions and Methods
0.00%
0 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ControlPlaneFactory | 0.00% | 0 / 13 | 0.00% | 0 / 2 | 12 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| createControlPlane | 0.00% | 0 / 12 | 0.00% | 0 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Control; | |
| 6 | ||
| 7 | use Psr\Log\LoggerInterface; | |
| 8 | use Stewart\Runtime\Broker\ControlPlane; | |
| 9 | use Stewart\Runtime\Broker\DisabledControlPlane; | |
| 10 | use Stewart\Runtime\Config\ControlConfig; | |
| 11 | use Stewart\Runtime\Config\ProjectRoot; | |
| 12 | use Stewart\Runtime\Control\Protocol\Codec\FrameCodec; | |
| 13 | use Stewart\Runtime\Control\Request\ControlRequestDispatcher; | |
| 14 | use Stewart\Runtime\Control\Server\ControlServer; | |
| 15 | use Stewart\Runtime\Control\Server\UnixSocketFile; | |
| 16 | use Stewart\Runtime\Exception\ConfigurationError; | |
| 17 | use Stewart\Runtime\Exception\ConfigurationException; | |
| 18 | use Stewart\Support\Time\Deadlines; | |
| 19 | ||
| 20 | final readonly class ControlPlaneFactory | |
| 21 | { | |
| 22 | public function __construct( | |
| 23 | private ControlConfig $control, | |
| 24 | private ControlRequestDispatcher $requests, | |
| 25 | private Deadlines $deadlines, | |
| 26 | private FrameCodec $codec, | |
| 27 | private LoggerInterface $logger, | |
| 28 | private UnixSocketFile $socketFile, | |
| 29 | private ProjectRoot $projectRoot, | |
| 30 | ) {} | |
| 31 | ||
| 32 | /** @throws ConfigurationException */ | |
| 33 | public function createControlPlane(): ControlPlane | |
| 34 | { | |
| 35 | if ($this->control->listen === null) { | |
| 36 | return new DisabledControlPlane(); | |
| 37 | } | |
| 38 | ||
| 39 | return new ControlServer( | |
| 40 | address: $this->control->listen, | |
| 41 | token: $this->control->token ?? throw ConfigurationException::createForReason(ConfigurationError::ControlTokenMissing), | |
| 42 | requests: $this->requests, | |
| 43 | deadlines: $this->deadlines, | |
| 44 | codec: $this->codec, | |
| 45 | logger: $this->logger, | |
| 46 | socketFile: $this->socketFile, | |
| 47 | projectRoot: $this->projectRoot, | |
| 48 | ); | |
| 49 | } | |
| 50 | } |