Passed
Push — master ( 46c3ee...445208 )
by Rafael
04:28
created

ResolverContext::setNodeDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Resolver;
12
13
use GraphQL\Type\Definition\ResolveInfo;
14
use Ynlo\GraphQLBundle\Definition\ExecutableDefinitionInterface;
15
use Ynlo\GraphQLBundle\Definition\ObjectDefinitionInterface;
16
use Ynlo\GraphQLBundle\Definition\Registry\Endpoint;
17
18
/**
19
 * Context used for resolvers
20
 */
21
class ResolverContext
22
{
23
    /**
24
     * @var Endpoint
25
     */
26
    protected $endpoint;
27
28
    /**
29
     * @var ExecutableDefinitionInterface
30
     */
31
    protected $definition;
32
33
    /**
34
     * @var mixed
35
     */
36
    protected $root;
37
38
    /**
39
     * @var ObjectDefinitionInterface
40
     */
41
    protected $node;
42
43
    /**
44
     * Array of arguments given
45
     *
46
     * @var array
47
     */
48
    protected $args = [];
49
50
    /**
51
     * @var ResolveInfo
52
     */
53
    protected $resolveInfo;
54
55
    /**
56
     * ResolverContext constructor.
57
     *
58
     * @param Endpoint                      $endpoint
59
     * @param ExecutableDefinitionInterface $definition
60
     * @param mixed                         $root
61
     * @param ObjectDefinitionInterface     $node
62
     * @param array                         $args
63
     * @param ResolveInfo                   $resolveInfo
64
     */
65 3
    public function __construct(
66
        Endpoint $endpoint,
67
        ?ExecutableDefinitionInterface $definition = null,
68
        $root = null,
69
        ?ObjectDefinitionInterface $node = null,
70
        array $args = [],
71
        ?ResolveInfo $resolveInfo = null
72
    ) {
73 3
        $this->endpoint = $endpoint;
74 3
        $this->definition = $definition;
75 3
        $this->root = $root;
76 3
        $this->node = $node;
77 3
        $this->args = $args;
78 3
        $this->resolveInfo = $resolveInfo;
79 3
    }
80
81
    /**
82
     * @return Endpoint
83
     */
84 1
    public function getEndpoint(): Endpoint
85
    {
86 1
        return $this->endpoint;
87
    }
88
89
    /**
90
     * @return ExecutableDefinitionInterface
91
     */
92 3
    public function getDefinition(): ExecutableDefinitionInterface
93
    {
94 3
        return $this->definition;
95
    }
96
97
    /**
98
     * @return mixed|null
99
     */
100 1
    public function getRoot()
101
    {
102 1
        return $this->root;
103
    }
104
105
    /**
106
     * @deprecated use getNode() instead
107
     *
108
     * @return ObjectDefinitionInterface|null
109
     */
110
    public function getNodeDefinition(): ?ObjectDefinitionInterface
111
    {
112
        return $this->getNode();
113
    }
114
115
    /**
116
     * @return ObjectDefinitionInterface|null
117
     */
118 1
    public function getNode(): ?ObjectDefinitionInterface
119
    {
120 1
        return $this->node;
121
    }
122
123
    /**
124
     * @return array
125
     */
126
    public function getArgs(): array
127
    {
128
        return $this->args;
129
    }
130
131
    /**
132
     * @return ResolveInfo
133
     */
134
    public function getResolveInfo(): ResolveInfo
135
    {
136
        return $this->resolveInfo;
137
    }
138
}
139