Test Failed
Push — master ( a0eed4...bb00ac )
by Kirill
149:40
created

InputValueNode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 7 2
A toValue() 0 11 2
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\Frontend\AST\Invocation;
11
12
use Railt\Io\Readable;
13
use Railt\Parser\Ast\RuleInterface;
14
use Railt\SDL\Frontend\AST\Definition\ArgumentDefinitionNode;
15
use Railt\SDL\IR\Value;
16
use Railt\SDL\IR\ValueInterface;
17
18
/**
19
 * Class InputValue
20
 */
21
class InputValueNode extends AbstractValueNode
22
{
23
    /**
24
     * @return \Generator|mixed
25
     */
26
    protected function parse()
27
    {
28
        /** @var ArgumentValueNode $argument */
29
        foreach ($this->find('ArgumentValue', 1) as $argument) {
30
            yield from $argument->toPrimitive();
31
        }
32
    }
33
34
    /**
35
     * @param Readable $file
36
     * @return ValueInterface
37
     */
38
    public function toValue(Readable $file): ValueInterface
39
    {
40
        $result = [];
41
42
        /** @var ArgumentValueNode $argument */
43
        foreach ($this->find('ArgumentValue', 1) as $argument) {
44
            $result[$argument->getFullName()] = $argument->toValue($file);
45
        }
46
47
        return (new Value($result))->in($file, $this->getOffset());
48
    }
49
}
50