Conditions | 4 |
Paths | 5 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
50 | 20 | protected function buildArguments(array $arguments, array $defaults = []) : string |
|
51 | { |
||
52 | 20 | $argumentsString = []; |
|
53 | 20 | $defaults = array_filter($defaults); |
|
54 | 20 | foreach ($arguments as $argumentName => $argumentType) { |
|
55 | // Group name with type |
||
56 | 9 | $argumentsString[] = ($argumentType !== null ? $argumentType . ' ' : '') . |
|
57 | 9 | '$' . $argumentName . |
|
58 | 9 | (array_key_exists($argumentName, $defaults) ? ' = ' . $defaults[$argumentName] : ''); |
|
59 | } |
||
60 | |||
61 | 20 | return implode(', ', $argumentsString); |
|
62 | } |
||
63 | } |
||
64 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: