Failed Conditions
Push — master ( a4f39b...12ee90 )
by Vladimir
11:17
created

ASTValidationContext   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDocument() 0 3 1
A reportError() 0 3 1
A __construct() 0 5 1
A getErrors() 0 3 1
A getSchema() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Validator;
6
7
use GraphQL\Error\Error;
8
use GraphQL\Language\AST\DocumentNode;
9
use GraphQL\Type\Schema;
10
11
abstract class ASTValidationContext
12
{
13
    /** @var DocumentNode */
14
    protected $ast;
15
16
    /** @var Error[] */
17
    protected $errors;
18
19
    /** @var Schema */
20
    protected $schema;
21
22 724
    public function __construct(DocumentNode $ast, ?Schema $schema = null)
23
    {
24 724
        $this->ast    = $ast;
25 724
        $this->schema = $schema;
26 724
        $this->errors = [];
27 724
    }
28
29 223
    public function reportError(Error $error)
30
    {
31 223
        $this->errors[] = $error;
32 223
    }
33
34
    /**
35
     * @return Error[]
36
     */
37 724
    public function getErrors()
38
    {
39 724
        return $this->errors;
40
    }
41
42
    /**
43
     * @return DocumentNode
44
     */
45 441
    public function getDocument()
46
    {
47 441
        return $this->ast;
48
    }
49
50 424
    public function getSchema() : ?Schema
51
    {
52 424
        return $this->schema;
53
    }
54
}
55