Completed
Push — master ( 4b751e...16bedf )
by Rafael
03:46
created

FilterContext::getParentContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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\Filter;
12
13
use Ynlo\GraphQLBundle\Definition\FieldDefinition;
14
use Ynlo\GraphQLBundle\Definition\FieldsAwareDefinitionInterface;
15
use Ynlo\GraphQLBundle\Definition\Registry\Endpoint;
16
use Ynlo\GraphQLBundle\Resolver\ResolverContext;
17
18
/**
19
 * Context where the filter is applied
20
 */
21
class FilterContext
22
{
23
    /**
24
     * @var ResolverContext
25
     */
26
    private $parentContext;
27
28
    /**
29
     * @var FieldsAwareDefinitionInterface
30
     */
31
    private $node;
32
33
    /**
34
     * @var FieldDefinition|null
35
     */
36
    private $field;
37
38
    /**
39
     * FilterContext constructor.
40
     *
41
     * @param ResolverContext                $parentContext
42
     * @param FieldsAwareDefinitionInterface $node
43
     * @param null|FieldDefinition           $field
44
     */
45 45
    public function __construct(ResolverContext $parentContext, FieldsAwareDefinitionInterface $node, ?FieldDefinition $field = null)
46
    {
47 45
        $this->parentContext = $parentContext;
48 45
        $this->node = $node;
49 45
        $this->field = $field;
50 45
    }
51
52
    /**
53
     * @return Endpoint
54
     */
55 1
    public function getEndpoint(): Endpoint
56
    {
57 1
        return $this->parentContext->getEndpoint();
58
    }
59
60
    /**
61
     * @return FieldsAwareDefinitionInterface
62
     */
63 9
    public function getNode(): FieldsAwareDefinitionInterface
64
    {
65 9
        return $this->node;
66
    }
67
68
    /**
69
     * @return null|FieldDefinition
70
     */
71 38
    public function getField(): ?FieldDefinition
72
    {
73 38
        return $this->field;
74
    }
75
76
    /**
77
     * @param null|FieldDefinition $field
78
     */
79 8
    public function setField(?FieldDefinition $field): void
80
    {
81 8
        $this->field = $field;
82 8
    }
83
84
    /**
85
     * @return ResolverContext
86
     */
87
    public function getParentContext(): ResolverContext
88
    {
89
        return $this->parentContext;
90
    }
91
}
92