for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* balloon
*
* @copyright Copryright (c) 2012-2018 gyselroth GmbH (https://gyselroth.com)
* @license GPL-3.0 https://opensource.org/licenses/GPL-3.0
*/
namespace Balloon\Filesystem\Storage;
use Balloon\Filesystem\Storage\Adapter\AdapterInterface;
use Balloon\Filesystem\Storage\Adapter\Smb;
use Balloon\Filesystem\Storage\Adapter\Smb\Factory as SmbFactory;
use Psr\Log\LoggerInterface;
class Factory
{
* Adapters.
const ADAPTERS = [
'smb' => Smb::class,
];
* Logger.
* @var LoggerInterface
protected $logger;
* SMB factory.
* @var SmbFactory
protected $smb_factory;
* Storage handler.
public function __construct(LoggerInterface $logger, SmbFactory $smb_factory)
$this->logger = $logger;
$this->smb_factory = $smb_factory;
}
* Create adapter.
public function build(array $options): AdapterInterface
$options = Validator::validate($options);
$adapter = self::ADAPTERS[$options['adapter']];
$adapter
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
return $this->smb_factory->build($options);
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.