Passed
Push — master ( 43996d...1595cb )
by Kirill
04:07
created

Executor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Spec;
13
14
use Phplrt\Visitor\Traverser;
15
use Phplrt\Visitor\TraverserInterface;
16
use Railt\SDL\Frontend\Ast\Node;
17
18
/**
19
 * Class Executor
20
 */
21
final class Executor
22
{
23
    /**
24
     * @var TraverserInterface
25
     */
26
    private TraverserInterface $traverser;
27
28
    /**
29
     * Executor constructor.
30
     *
31
     * @param SpecificationInterface $spec
32
     */
33
    public function __construct(SpecificationInterface $spec)
34
    {
35
        $this->traverser = new Traverser([$spec]);
36
    }
37
38
    /**
39
     * @param iterable|Node[] $ast
40
     * @return iterable|Node[]
41
     */
42
    public function execute(iterable $ast): iterable
43
    {
44
        return $this->traverser->traverse($ast);
45
    }
46
}
47