for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Compressy.
*
* (c) Alchemy <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gocobachi\Compressy\Parser;
use Gocobachi\Compressy\Exception\InvalidArgumentException;
class ParserFactory
{
private static $zipDateFormat = 'Y-m-d H:i';
/**
* @param string $format Date format used to parse ZIP file listings
public static function setZipDateFormat($format)
self::$zipDateFormat = $format;
}
* Maps the corresponding parser to the selected adapter
* @param string $adapterName An adapter name
* @return ParserInterface
* @throws InvalidArgumentException In case no parser were found
public static function create($adapterName)
switch ($adapterName) {
case 'gnu-tar':
return new GNUTarOutputParser();
break;
break
The break statement is not necessary if it is preceded for example by a return statement:
return
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.
case
case 'bsd-tar':
return new BSDTarOutputParser();
case 'zip':
return new ZipOutputParser(self::$zipDateFormat);
default:
throw new InvalidArgumentException(sprintf('No parser available for %s adapter', $adapterName));
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.