Total Complexity | 6 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
18 | final class Construct implements Constructor |
||
19 | { |
||
20 | private $value; |
||
21 | |||
22 | 224 | private function __construct(string $value) |
|
23 | { |
||
24 | 224 | $this->value = $value; |
|
25 | 224 | } |
|
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | 224 | public static function fromString(Str $value): Constructor |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 115 | public function __invoke(...$arguments): object |
|
39 | { |
||
40 | 115 | $class = (string) $this->value; |
|
41 | |||
42 | 115 | $arguments = Sequence::of(...$arguments)->map(static function($argument) { |
|
43 | 19 | if ($argument instanceof Lazy) { |
|
44 | 15 | return $argument->load(); |
|
45 | } |
||
46 | |||
47 | 16 | return $argument; |
|
48 | 115 | }); |
|
49 | |||
50 | 114 | return new $class(...$arguments); |
|
51 | } |
||
52 | |||
53 | 7 | public function compile(CompiledArgument ...$arguments): CompiledConstructor |
|
54 | { |
||
55 | 7 | return new CompiledConstruct($this->value, ...$arguments); |
|
56 | } |
||
57 | |||
58 | 24 | public function __toString(): string |
|
61 | } |
||
62 | } |
||
63 |