rector/src/Dispatcher/NodeDispatcher.php
TomasVotruba 764ce4bb08 init
2017-07-15 19:01:21 +02:00

30 lines
678 B
PHP

<?php declare(strict_types=1);
namespace Rector\Dispatcher;
use PhpParser\Node;
use Rector\Contract\Dispatcher\ReconstructorInterface;
final class NodeDispatcher
{
/**
* @var ReconstructorInterface[]
*/
private $reconstructors;
public function addReconstructor(ReconstructorInterface $reconstructor): void
{
$this->reconstructors[] = $reconstructor;
}
public function dispatch(Node $node): void
{
// todo: build hash map
foreach ($this->reconstructors as $reconstructor) {
if ($reconstructor->isCandidate($node)) {
$reconstructor->reconstruct($node);
}
}
}
}