Lines
100.00%
5 / 5
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ControlConfig | 100.00% | 5 / 5 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| fromSection | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Config; | |
| 6 | ||
| 7 | use SensitiveParameter; | |
| 8 | use Stewart\Runtime\Exception\ConfigurationException; | |
| 9 | ||
| 10 | final readonly class ControlConfig | |
| 11 | { | |
| 12 | public function __construct( | |
| 13 | public ?ControlAddress $listen, | |
| 14 | #[SensitiveParameter] | |
| 15 | public ?string $token, | |
| 16 | ) {} | |
| 17 | ||
| 18 | /** @throws ConfigurationException */ | |
| 19 | public static function fromSection(#[SensitiveParameter] ConfigSection $control): self | |
| 20 | { | |
| 21 | return new self( | |
| 22 | listen: $control->findSwitchableValue('listen', ControlAddress::parse(...)), | |
| 23 | token: $control->findSwitchableValue('token', strval(...)), | |
| 24 | ); | |
| 25 | } | |
| 26 | } |