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

GenericTypes::assert()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 2
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