| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public static function createFromFileName($filename) |
||
| 13 | { |
||
| 14 | if (!is_file($filename) || !is_readable($filename)) { |
||
| 15 | throw new \InvalidArgumentException("Cannot read configuration file '{$filename}'"); |
||
| 16 | } |
||
| 17 | |||
| 18 | switch (pathinfo($filename, PATHINFO_EXTENSION)) { |
||
| 19 | case 'json': |
||
| 20 | return new ConfigFileReaderJson($filename); |
||
| 21 | case 'ini': |
||
| 22 | return new ConfigFileReaderIni($filename); |
||
| 23 | break; |
||
|
|
|||
| 24 | default: |
||
| 25 | throw new \InvalidArgumentException("Unsupported config file format: '$filename'"); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | } |
||
| 29 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.