| Total Complexity | 6 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | final class Stream implements Constructor |
||
| 17 | { |
||
| 18 | private $type; |
||
| 19 | |||
| 20 | 11 | private function __construct(string $type) |
|
| 21 | { |
||
| 22 | 11 | $this->type = $type; |
|
| 23 | 11 | } |
|
| 24 | |||
| 25 | /** |
||
| 26 | * {@inheritdoc} |
||
| 27 | */ |
||
| 28 | 16 | public static function fromString(Str $value): Constructor |
|
| 29 | { |
||
| 30 | 16 | if (!$value->matches('~^stream<\S+>$~')) { |
|
| 31 | 12 | throw new ValueNotSupported((string) $value); |
|
| 32 | } |
||
| 33 | |||
| 34 | 11 | $components = $value->capture('~^stream<(?<type>\S+)>$~'); |
|
| 35 | |||
| 36 | 11 | return new self((string) $components->get('type')); |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc} |
||
| 41 | */ |
||
| 42 | 3 | public function __invoke(...$arguments): object |
|
| 43 | { |
||
| 44 | 3 | return new LazyStream($this->type, ...$arguments); |
|
| 45 | } |
||
| 46 | |||
| 47 | 5 | public function compile(CompiledArgument ...$arguments): CompiledConstructor |
|
| 48 | { |
||
| 49 | 5 | return new CompiledStream($this->type, ...$arguments); |
|
| 50 | } |
||
| 51 | |||
| 52 | 2 | public function __toString(): string |
|
| 55 | } |
||
| 56 | } |
||
| 57 |