for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Moodle component manager.
*
* @author Luke Carrier <[email protected]>
* @copyright 2016 Luke Carrier
* @license GPL-3.0+
*/
namespace ComponentManager\Platform;
use ComponentManager\Exception\PlatformException;
use Symfony\Component\Filesystem\Filesystem;
class PlatformFactory {
* Filesystem.
* @var Filesystem
protected $filesystem;
* Initialiser.
* @param Filesystem $filesystem
public function __construct(Filesystem $filesystem) {
$this->filesystem = $filesystem;
}
* Get the platform with the specified name.
* @param string $platformName The name of the platform (retrieved from
* PHP_OS).
* @return Platform
* @throws PlatformException
public function getPlatform($platformName) {
switch ($platformName) {
case 'Darwin':
case 'FreeBSD':
case 'Linux':
return new LinuxPlatform($this->filesystem);
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.
case 'WINNT':
case 'Windows':
return new WindowsPlatform($this->filesystem);
default:
throw new PlatformException(
sprintf('Unsupported platform %s', PHP_OS),
PlatformException::CODE_UNKNOWN_PLATFORM);
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.