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

ValidationContext::getErrors()   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 0
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