for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Dumkaaa\BxOptimize;
use Dumkaaa\BxOptimize\Handler\HandlerInterface;
class Optimizer implements OptimizerInterface
{
/** @var Finder\FinderInterface null */
protected $finder = null;
/** @var Handler\HandlerInterface */
protected $handlers;
/** @var array Массив найденных файлов для обработки */
private $files = [];
/**
* {@inheritdoc}
*/
public function __construct(Finder\FinderInterface $finder = null, Handler\HandlerProcessor $handler = null)
$this->finder = $finder;
$this->handlers = $handler->getHandlers();
$handler
null
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:
function someFunction(A $objectMaybe = null) { if ($objectMaybe instanceof A) { $objectMaybe->doSomething(); } }
}
public function optimize()
$this->findFiles();
$this->setQueue();
$this->handleQueue();
private function setQueue()
/** @var HandlerInterface $handler */
foreach ($this->handlers as $handler) {
$this->handlers
object<Dumkaaa\BxOptimiz...ndler\HandlerInterface>
foreach ($this->files as $file) {
if (!$handler->canHandleFile($file)) {
continue;
} else {
$handler->queueFile($file);
private function handleQueue()
$handler->handleQueue();
private function findFiles()
$this->files = $this->finder->findFiles();
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: