| Conditions | 10 |
| Paths | 32 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 32.8211 |
| 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 |
||
| 85 | 1 | protected function parse(string $file, string $name): array |
|
| 86 | { |
||
| 87 | 1 | $type = pathinfo($file, PATHINFO_EXTENSION); |
|
| 88 | |||
| 89 | 1 | switch ($type) { |
|
| 90 | 1 | case 'php': |
|
|
1 ignored issue
–
show
|
|||
| 91 | 1 | $config = include $file; |
|
| 92 | 1 | break; |
|
| 93 | case 'yml': |
||
|
1 ignored issue
–
show
|
|||
| 94 | case 'yaml': |
||
|
1 ignored issue
–
show
|
|||
| 95 | if (function_exists('yaml_parse_file')) { |
||
|
1 ignored issue
–
show
|
|||
| 96 | $config = yaml_parse_file($file); |
||
| 97 | } |
||
|
1 ignored issue
–
show
|
|||
| 98 | break; |
||
| 99 | case 'ini': |
||
|
1 ignored issue
–
show
|
|||
| 100 | $config = parse_ini_file($file, true, INI_SCANNER_TYPED) ?: []; |
||
| 101 | break; |
||
| 102 | case 'json': |
||
|
1 ignored issue
–
show
|
|||
| 103 | $config = json_decode(file_get_contents($file), true); |
||
| 104 | break; |
||
| 105 | } |
||
| 106 | |||
| 107 | 1 | return isset($config) && is_array($config) ? $this->set($config, strtolower($name)) : []; |
|
| 108 | } |
||
| 193 |