RepeatableDirectives   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A assert() 0 8 3
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\Constraint;
13
14
use Phplrt\Contracts\Ast\NodeInterface;
15
use Railt\SDL\Spec\SpecificationInterface;
16
use Railt\SDL\Exception\TypeErrorException;
17
use Phplrt\Source\Exception\NotAccessibleException;
18
use Railt\SDL\Frontend\Ast\Definition\DirectiveDefinitionNode;
19
20
/**
21
 * Class RepeatableDirectives
22
 */
23
class RepeatableDirectives extends Constraint
24
{
25
    /**
26
     * @param NodeInterface $node
27
     * @param SpecificationInterface $spec
28
     * @return void
29
     * @throws TypeErrorException
30
     * @throws NotAccessibleException
31
     * @throws \RuntimeException
32
     */
33
    public static function assert(NodeInterface $node, SpecificationInterface $spec): void
34
    {
35
        if (! $node instanceof DirectiveDefinitionNode) {
36
            return;
37
        }
38
39
        if ($node->repeatable) {
40
            throw TypeErrorException::fromAst(static::notSupported($spec), $node);
41
        }
42
    }
43
}
44