Test Setup Failed
Push — master ( 1595cb...1df194 )
by Kirill
02:11
created

GenericTypes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 15
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\Exception\TypeErrorException;
16
use Railt\SDL\Frontend\Ast\TypeName;
17
use Railt\SDL\Spec\SpecificationInterface;
18
19
/**
20
 * Class GenericTypes
21
 */
22
class GenericTypes extends Constraint
23
{
24
    /**
25
     * @param NodeInterface $node
26
     * @param SpecificationInterface $spec
27
     * @return void
28
     */
29
    public static function assert(NodeInterface $node, SpecificationInterface $spec): void
30
    {
31
        if (! $node instanceof TypeName) {
32
            return;
33
        }
34
35
        if ($node->arguments !== []) {
36
            throw TypeErrorException::fromAst(static::notSupported($spec), $node);
37
        }
38
    }
39
}
40