Trismegiste\Mondrian\Visitor\VisitorGateway::__construct PHP Method

__construct() public method

Ctor
public __construct ( array $visitor, ReflectionContext $ref, GraphContext $grf, Trismegiste\Mondrian\Graph\Graph $g )
$visitor array a list of State
$ref Trismegiste\Mondrian\Transform\ReflectionContext
$grf Trismegiste\Mondrian\Transform\GraphContext
$g Trismegiste\Mondrian\Graph\Graph
    public function __construct(array $visitor, ReflectionContext $ref, GraphContext $grf, Graph $g)
    {
        if (!count($visitor)) {
            throw new \InvalidArgumentException("The visitors list cannot be empty");
        }
        $this->graphCtx = $grf;
        $this->graph = $g;
        $this->reflectionCtx = $ref;
        foreach ($visitor as $k => $v) {
            if (!$v instanceof State\State) {
                throw new \InvalidArgumentException("Invalid visitor for index {$k}");
            }
            $v->setContext($this);
            $this->stateList[$v->getName()] = $v;
        }
        $this->stateStack[0] = ['node' => null, 'state' => $visitor[0], 'key' => $visitor[0]->getName()];
    }

Usage Example

Example #1
0
 public function __construct(ReflectionContext $ref, GraphContext $grf, Graph $g)
 {
     $visitor = [new \Trismegiste\Mondrian\Visitor\State\PackageLevel(), new FileLevel(), new ClassLevel(), new InterfaceLevel(), new TraitLevel()];
     parent::__construct($visitor, $ref, $grf, $g);
 }