Total Complexity | 7 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
19 | final class ServiceFactory implements Constructor |
||
20 | { |
||
21 | private $method; |
||
22 | |||
23 | 4 | private function __construct(string $method) |
|
24 | { |
||
25 | 4 | $this->method = $method; |
|
26 | 4 | } |
|
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 18 | public static function fromString(Str $value): Constructor |
|
32 | { |
||
33 | 18 | if (!$value->matches('~^\$factory->\S+$~')) { |
|
34 | 14 | throw new ValueNotSupported((string) $value); |
|
35 | } |
||
36 | |||
37 | 4 | [, $method] = $value->split('->'); |
|
38 | |||
39 | 4 | return new self((string) $method); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function __invoke(...$arguments): object |
||
56 | } |
||
57 | |||
58 | 1 | public function compile(CompiledArgument ...$arguments): CompiledConstructor |
|
59 | { |
||
60 | 1 | return new CompiledServiceFactory($this->method, ...$arguments); |
|
61 | } |
||
62 | |||
63 | 1 | public function __toString(): string |
|
66 | } |
||
67 | } |
||
68 |