gocobachi /
compressy
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of Compressy. |
||
| 5 | * |
||
| 6 | * (c) Alchemy <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Gocobachi\Compressy\Parser; |
||
| 13 | |||
| 14 | use Gocobachi\Compressy\Exception\InvalidArgumentException; |
||
| 15 | |||
| 16 | class ParserFactory |
||
| 17 | { |
||
| 18 | |||
| 19 | private static $zipDateFormat = 'Y-m-d H:i'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param string $format Date format used to parse ZIP file listings |
||
| 23 | */ |
||
| 24 | public static function setZipDateFormat($format) |
||
| 25 | { |
||
| 26 | self::$zipDateFormat = $format; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Maps the corresponding parser to the selected adapter |
||
| 31 | * |
||
| 32 | * @param string $adapterName An adapter name |
||
| 33 | * |
||
| 34 | * @return ParserInterface |
||
| 35 | * |
||
| 36 | * @throws InvalidArgumentException In case no parser were found |
||
| 37 | */ |
||
| 38 | public static function create($adapterName) |
||
| 39 | { |
||
| 40 | switch ($adapterName) { |
||
| 41 | case 'gnu-tar': |
||
| 42 | return new GNUTarOutputParser(); |
||
| 43 | break; |
||
|
0 ignored issues
–
show
|
|||
| 44 | case 'bsd-tar': |
||
| 45 | return new BSDTarOutputParser(); |
||
| 46 | break; |
||
| 47 | case 'zip': |
||
| 48 | return new ZipOutputParser(self::$zipDateFormat); |
||
| 49 | break; |
||
| 50 | |||
| 51 | default: |
||
| 52 | throw new InvalidArgumentException(sprintf('No parser available for %s adapter', $adapterName)); |
||
| 53 | break; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 |
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.