Passed
Pull Request — master (#118)
by Christoffer
02:13
created

ValidationContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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