Completed
Pull Request — master (#53)
by Christoffer
02:09
created

SelectionSetTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setSelectionSet() 0 4 1
A hasSelectionSet() 0 3 1
A getSelectionSet() 0 3 1
A getSelectionSetAsArray() 0 3 2
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node;
4
5
trait SelectionSetTrait
6
{
7
8
    /**
9
     * @var SelectionSetNode|null
10
     */
11
    protected $selectionSet;
12
13
    /**
14
     * @return bool
15
     */
16
    public function hasSelectionSet(): bool
17
    {
18
        return null !== $this->selectionSet;
19
    }
20
21
    /**
22
     * @return SelectionSetNode|null
23
     */
24
    public function getSelectionSet(): ?SelectionSetNode
25
    {
26
        return $this->selectionSet;
27
    }
28
29
    /**
30
     * @return array|null
31
     */
32
    public function getSelectionSetAsArray(): ?array
33
    {
34
        return null !== $this->selectionSet ? $this->selectionSet->toArray() : null;
35
    }
36
37
    /**
38
     * @param SelectionSetNode|null $selectionSet
39
     * @return $this
40
     */
41
    public function setSelectionSet(?SelectionSetNode $selectionSet)
42
    {
43
        $this->selectionSet = $selectionSet;
44
        return $this;
45
    }
46
}
47