Conditions | 7 |
Paths | 16 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 7.392 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
48 | 5 | public function generateCode(): string |
|
49 | { |
||
50 | 5 | $code = ''; |
|
51 | 5 | if ($this->type) { |
|
52 | 3 | $code .= $this->type . ' '; |
|
53 | } |
||
54 | 5 | if ($this->variadic) { |
|
55 | 1 | $code .= '...'; |
|
56 | } |
||
57 | 5 | $code .= "\${$this->name}"; |
|
58 | |||
59 | 5 | if ($this->hasDefaultValue) { |
|
60 | 1 | $defaultValue = var_export($this->defaultValue, true); |
|
61 | 1 | if (is_string($this->defaultValue)) { |
|
62 | $parts = explode('::', $this->defaultValue); |
||
63 | if ($parts[0] === 'self' || class_exists($parts[0])) { |
||
64 | $defaultValue = $this->defaultValue; |
||
65 | } |
||
66 | } |
||
67 | 1 | $code .= ' = ' . $defaultValue; |
|
68 | } |
||
69 | |||
70 | 5 | return $code; |
|
71 | } |
||
72 | |||
78 |