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

InputValueNode::toValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
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