Conditions | 2 |
Paths | 1 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | public function __invoke(Argument $argument) |
||
24 | { |
||
25 | $stringTypeFactory = Parameter::factory(function() use ($argument) { |
||
26 | if ($argument->isUnionType()) { |
||
27 | throw new \LogicException(\sprintf('ValueFactory does not support union types. Inject "%s" instead.', Argument::class)); |
||
28 | } |
||
29 | |||
30 | return $argument->type(); |
||
31 | }); |
||
32 | |||
33 | return Callback::createFor($this->factory) |
||
34 | ->invoke(Parameter::union( |
||
35 | Parameter::typed(Argument::class, $argument), |
||
36 | Parameter::typed('array', $argument->types()), |
||
37 | Parameter::typed('string', $stringTypeFactory), |
||
38 | Parameter::untyped($stringTypeFactory) |
||
39 | )->optional()) |
||
40 | ; |
||
43 |