Conditions | 4 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
18 | 3 | public function renderInject(Directive $directive): string |
|
19 | { |
||
20 | 3 | if (\count($directive->values) < 2 || (string) $directive->values[0] === '') { |
|
21 | 1 | throw new DirectiveException( |
|
22 | 1 | 'Unable to call @inject directive, 2 values required', |
|
23 | 1 | $directive->getContext() |
|
|
|||
24 | 1 | ); |
|
25 | } |
||
26 | |||
27 | 2 | if ($directive->values[0][0] === '$') { |
|
28 | 1 | return \sprintf( |
|
29 | 1 | '<?php %s = $this->container->get(%s); ?>', |
|
30 | 1 | $directive->values[0], |
|
31 | 1 | $directive->values[1] |
|
32 | 1 | ); |
|
33 | } |
||
34 | |||
35 | 1 | return \sprintf( |
|
36 | 1 | '<?php $%s = $this->container->get(%s); ?>', |
|
37 | 1 | \trim($directive->values[0], '\'"'), |
|
38 | 1 | $directive->values[1] |
|
39 | 1 | ); |
|
42 |