Passed
Pull Request — master (#169)
by Quang
03:16
created

CoercedValue::hasErrors()   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\Execution;
4
5
use Digia\GraphQL\Error\GraphQLException;
6
7
/**
8
 * Class CoercedValue
9
 * @package Digia\GraphQL\Execution
10
 */
11
class CoercedValue
12
{
13
    /**
14
     * @var GraphQLException[]
15
     */
16
    private $errors;
17
18
    /**
19
     * @var mixed|null
20
     */
21
    private $value;
22
23
    /**
24
     * CoercedValue constructor.
25
     * @param            $value
26
     * @param array|null $errors
27
     */
28
    public function __construct($value, ?array $errors)
29
    {
30
        $this->errors = $errors;
31
        $this->value  = $value;
32
    }
33
34
    /**
35
     * @return GraphQLException[]
36
     */
37
    public function getErrors(): array
38
    {
39
        return $this->errors ?? [];
40
    }
41
42
    /**
43
     * @return bool
44
     */
45
    public function hasErrors(): bool
46
    {
47
        return !empty($this->errors);
48
    }
49
50
    /**
51
     * @param GraphQLException[] $errors
52
     */
53
    public function setErrors(array $errors): void
54
    {
55
        $this->errors = $errors;
56
    }
57
58
    /**
59
     * @return mixed
60
     */
61
    public function getValue()
62
    {
63
        return $this->value;
64
    }
65
66
    /**
67
     * @param mixed $value
68
     */
69
    public function setValue($value): void
70
    {
71
        $this->value = $value;
72
    }
73
}