Conditions | 7 |
Paths | 32 |
Total Lines | 36 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 25 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
34 | 11 | protected static function doGenerate(\ReflectionMethod $method): string |
|
35 | { |
||
36 | 11 | $visibility = static::getVisibility($method); |
|
37 | |||
38 | 11 | $static = $method->isStatic() ? 'static' : ''; |
|
39 | |||
40 | 11 | $parameters = $method->getParameters(); |
|
41 | 11 | $parametersCode = []; |
|
42 | 11 | if (is_array($parameters)) { |
|
43 | 11 | foreach ($parameters as $parameter) { |
|
44 | 10 | $parametersCode[] = ParameterTemplate::generate($parameter); |
|
45 | } |
||
46 | } |
||
47 | |||
48 | 11 | $originalReturnType = $method->getReturnType(); |
|
49 | 11 | $returnType = $originalReturnType |
|
50 | 5 | ? ReturnTypeTemplate::generate($method) |
|
51 | 11 | : ''; |
|
52 | |||
53 | 11 | $returnStatement = null === $originalReturnType || 'void' !== (string)$originalReturnType |
|
54 | 11 | ? 'return' |
|
55 | 11 | : ''; |
|
56 | |||
57 | 11 | $methodName = $method->name; |
|
58 | |||
59 | 11 | return sprintf( |
|
60 | 11 | self::TEMPLATE, |
|
61 | 11 | $visibility, |
|
62 | 11 | $static, |
|
63 | 11 | $methodName, |
|
64 | 11 | implode(',', $parametersCode), |
|
65 | 11 | $returnType, |
|
66 | 11 | $returnStatement, |
|
67 | 11 | $methodName |
|
68 | ); |
||
69 | } |
||
70 | } |
||
71 |