ValidationRule   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 5
c 1
b 0
f 0
dl 0
loc 37
ccs 0
cts 8
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A getName() 0 3 2
A getSDLVisitor() 0 3 1
A getVisitor() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Validator\Rules;
6
7
use GraphQL\Validator\SDLValidationContext;
8
use GraphQL\Validator\ValidationContext;
9
use function class_alias;
10
11
abstract class ValidationRule
12
{
13
    /** @var string */
14
    protected $name;
15
16
    public function getName()
17
    {
18
        return $this->name ?: static::class;
19
    }
20
21
    public function __invoke(ValidationContext $context)
22
    {
23
        return $this->getVisitor($context);
24
    }
25
26
    /**
27
     * Returns structure suitable for GraphQL\Language\Visitor
28
     *
29
     * @see \GraphQL\Language\Visitor
30
     *
31
     * @return mixed[]
32
     */
33
    public function getVisitor(ValidationContext $context)
34
    {
35
        return [];
36
    }
37
38
    /**
39
     * Returns structure suitable for GraphQL\Language\Visitor
40
     *
41
     * @see \GraphQL\Language\Visitor
42
     *
43
     * @return mixed[]
44
     */
45
    public function getSDLVisitor(SDLValidationContext $context)
46
    {
47
        return [];
48
    }
49
}
50
51
class_alias(ValidationRule::class, 'GraphQL\Validator\Rules\AbstractValidationRule');
52