Test Failed
Push — master ( b7ab7b...94ee03 )
by Kirill
02:59
created

DefinitionBuilder::createTypeArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 12
rs 9.8666
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\Builder;
11
12
use Railt\Parser\Ast\RuleInterface;
13
use Railt\SDL\Frontend\Builder\Definition\Definition;
14
use Railt\SDL\Frontend\Context\ContextInterface;
15
use Railt\SDL\IR\Type;
16
17
/**
18
 * Class DefinitionBuilder
19
 */
20
class DefinitionBuilder extends BaseBuilder
21
{
22
    /**
23
     * @var string[]
24
     */
25
    private const TYPE_DEFINITIONS = [
26
        'ObjectDefinition'    => Type::OBJECT,
27
        'SchemaDefinition'    => Type::SCHEMA,
28
        'DirectiveDefinition' => Type::DIRECTIVE,
29
    ];
30
31
    /**
32
     * @param RuleInterface $rule
33
     * @return bool
34
     */
35
    public function match(RuleInterface $rule): bool
36
    {
37
        return (bool)(self::TYPE_DEFINITIONS[$rule->getName()] ?? false);
38
    }
39
40
    /**
41
     * @param ContextInterface $ctx
42
     * @param RuleInterface $rule
43
     * @return mixed|\Generator|void
44
     */
45
    public function reduce(ContextInterface $ctx, RuleInterface $rule)
46
    {
47
        /** @var Definition $def */
48
        $def = yield $rule->first('> #TypeDefinition');
49
50
        dd($def);
51
    }
52
}
53