Passed
Pull Request — master (#159)
by Christoffer
03:39
created

ValidationContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrors() 0 3 1
A __construct() 0 3 1
A reportError() 0 3 1
A getSchema() 0 3 1
1
<?php
2
3
namespace Digia\GraphQL\SchemaValidation;
4
5
use Digia\GraphQL\Error\SchemaValidationException;
6
use Digia\GraphQL\Error\ValidationExceptionInterface;
7
use Digia\GraphQL\Type\SchemaInterface;
8
9
class ValidationContext implements ValidationContextInterface
10
{
11
    /**
12
     * @var SchemaInterface
13
     */
14
    protected $schema;
15
16
    /**
17
     * @var SchemaValidationException[]
18
     */
19
    protected $errors = [];
20
21
    /**
22
     * SchemaValidationContext constructor.
23
     * @param SchemaInterface $schema
24
     */
25
    public function __construct(SchemaInterface $schema)
26
    {
27
        $this->schema = $schema;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function reportError(ValidationExceptionInterface $error)
34
    {
35
        $this->errors[] = $error;
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function getErrors(): array
42
    {
43
        return $this->errors;
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function getSchema(): SchemaInterface
50
    {
51
        return $this->schema;
52
    }
53
}
54