for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Hal\Application\Config\File;
class ConfigFileReaderFactory
{
/**
* @param string $filename
*
* @return ConfigFileReaderInterface
*/
public static function createFromFileName($filename)
if (!is_file($filename) || !is_readable($filename)) {
throw new \InvalidArgumentException("Cannot read configuration file '{$filename}'");
}
switch (pathinfo($filename, PATHINFO_EXTENSION)) {
case 'json':
return new ConfigFileReaderJson($filename);
case 'ini':
return new ConfigFileReaderIni($filename);
break;
break
The break statement is not necessary if it is preceded for example by a return statement:
switch ($x) { case 1: return 'foo'; break; // This break is not necessary and can be left off. }
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.
default:
throw new \InvalidArgumentException("Unsupported config file format: '$filename'");
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.