Failed Conditions
Push — master ( e31947...cc39b3 )
by Šimon
11s
created

ValidationRule::getName()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Validator\Rules;
6
7
use GraphQL\Validator\ValidationContext;
8
use function class_alias;
9
use function get_class;
10
11
abstract class ValidationRule
12
{
13
    /** @var string */
14
    protected $name;
15
16
    public function getName()
17
    {
18
        return $this->name ?: get_class($this);
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
     * @return mixed[]
31
     */
32
    abstract public function getVisitor(ValidationContext $context);
33
}
34
35
class_alias(ValidationRule::class, 'GraphQL\Validator\Rules\AbstractValidationRule');
36