Lines
100.00%
6 / 6
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ExposeConfig | 100.00% | 6 / 6 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| fromSection | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Config; | |
| 6 | ||
| 7 | use Stewart\Client\Component\ComponentInstance; | |
| 8 | use Stewart\Contracts\Time\Duration; | |
| 9 | use Stewart\Runtime\Exception\ConfigurationException; | |
| 10 | ||
| 11 | final readonly class ExposeConfig | |
| 12 | { | |
| 13 | private const int LONGEST_COMMAND_TIMEOUT_THE_COMPONENT_ACCEPTS_SECONDS = 300; | |
| 14 | ||
| 15 | public function __construct( | |
| 16 | public ComponentInstance $instance, | |
| 17 | public Duration $commandTimeout, | |
| 18 | public bool $prune = true, | |
| 19 | ) {} | |
| 20 | ||
| 21 | /** @throws ConfigurationException */ | |
| 22 | public static function fromSection(ConfigSection $expose): self | |
| 23 | { | |
| 24 | return new self( | |
| 25 | $expose->readParsedValue('instance', ComponentInstance::parse(...)), | |
| 26 | $expose->readDuration('command_timeout', Duration::milliseconds(1), Duration::seconds(self::LONGEST_COMMAND_TIMEOUT_THE_COMPONENT_ACCEPTS_SECONDS)), | |
| 27 | $expose->readBool('prune'), | |
| 28 | ); | |
| 29 | } | |
| 30 | } |