Conditions | 6 |
Paths | 32 |
Total Lines | 38 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 26 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
27 | 11 | protected static function doGenerate(\ReflectionParameter $parameter): string |
|
28 | { |
||
29 | try { |
||
30 | 11 | $defaultValue = !$parameter->allowsNull() |
|
31 | 11 | ? var_export($parameter->getDefaultValue(), true) |
|
32 | 11 | : 'null'; |
|
33 | |||
34 | 11 | $defaultValue = '=' . $defaultValue; |
|
35 | 10 | } catch (\ReflectionException $exception) { |
|
36 | 10 | $defaultValue = ''; |
|
37 | } |
||
38 | |||
39 | 11 | $type = $parameter->getType() |
|
40 | 11 | ? (string)$parameter->getType() |
|
41 | 11 | : ''; |
|
42 | |||
43 | 11 | $isPassedByReference = $parameter->isPassedByReference() |
|
44 | 5 | ? '&' |
|
45 | 11 | : ''; |
|
46 | |||
47 | 11 | $isVariadic = ''; |
|
48 | 11 | if ($parameter->isVariadic()) { |
|
49 | 4 | $isVariadic = '...'; |
|
50 | 4 | $isPassedByReference = ''; |
|
51 | 4 | $defaultValue = ''; |
|
52 | } |
||
53 | |||
54 | 11 | $name = '$' . $parameter->name; |
|
55 | |||
56 | 11 | return sprintf( |
|
57 | 11 | self::TEMPLATE, |
|
58 | 11 | $type, |
|
59 | 11 | $isVariadic, |
|
60 | 11 | $isPassedByReference, |
|
61 | 11 | $name, |
|
62 | 11 | $defaultValue |
|
63 | ); |
||
64 | } |
||
65 | } |
||
66 |