| Conditions | 10 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 16 | protected function setProperties(array $properties, array $mappings) |
||
| 17 | { |
||
| 18 | foreach ($properties as $key => $value) { |
||
| 19 | if (array_key_exists($key, $mappings)) { |
||
| 20 | if (is_array($value) && is_array($mappings) && $key !== 'style' && $key !== 'defaultStyle') { |
||
| 21 | /** |
||
| 22 | * @var array $value |
||
| 23 | */ |
||
| 24 | if (array_key_exists('__multi', $mappings[$key]) && $mappings[$key]['__multi'] === true) { |
||
| 25 | foreach ($value as $_key => $_value) { |
||
| 26 | $this->setPropertiesByKey($_key, $_value, $mappings[$key]); |
||
| 27 | } |
||
| 28 | } else { |
||
| 29 | $this->setProperties($value, $mappings[$key]); |
||
| 30 | } |
||
| 31 | } else { |
||
| 32 | $mappings[$key]($value); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 56 |