Completed
Pull Request — master (#18)
by Quang
03:15
created

ExecutionResult::getErrors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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