Valinor/tests/Fake/Mapper/Tree/Visitor/FakeShellVisitor.php
Romain Canon 396f64a524 feat: initial release
🎉
2021-11-28 18:21:56 +01:00

34 lines
697 B
PHP

<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\Fake\Mapper\Tree\Visitor;
use CuyZ\Valinor\Mapper\Tree\Shell;
use CuyZ\Valinor\Mapper\Tree\Visitor\ShellVisitor;
final class FakeShellVisitor implements ShellVisitor
{
/** @var null|callable(Shell): Shell */
private $callback;
/**
* @param null|callable(Shell): Shell $callback
*/
public function __construct(callable $callback = null)
{
if ($callback) {
$this->callback = $callback;
}
}
public function visit(Shell $shell): Shell
{
if (! isset($this->callback)) {
return $shell;
}
return ($this->callback)($shell);
}
}