SelectionField::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 13

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 13
nc 2
nop 6
crap 2
1
<?php
2
3
namespace HansOtt\GraphQL\Query;
4
5 View Code Duplication
final class SelectionField extends NodeBase implements Selection
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    public $name;
8
    public $alias;
9
    public $arguments;
10
    public $directives;
11
    public $selectionSet;
12
13
    /**
14
     * @param string|null $alias
15
     * @param string $name
16
     * @param Argument[] $arguments
17
     * @param Directive[] $directives
18
     * @param SelectionSet|null $selectionSet
19
     * @param Location|null $location
20
     */
21 51
    public function __construct(
22
        $alias = null,
23
        $name,
24
        array $arguments = array(),
25
        array $directives = array(),
26
        SelectionSet $selectionSet = null,
27
        Location $location = null
28
    ) {
29 51
        parent::__construct($location);
30 51
        $this->alias = $alias ? (string) $alias : null;
31 51
        $this->name = (string) $name;
32 51
        $this->arguments = $arguments;
33 51
        $this->directives = $directives;
34 51
        $this->selectionSet = $selectionSet;
35 51
    }
36
37 3
    public function getChildren()
38
    {
39 3
        $children = array();
40
41 3
        foreach ($this->arguments as $variable) {
42 3
            $children[] = $variable;
43 3
        }
44
45 3
        foreach ($this->directives as $directive) {
46 3
            $children[] = $directive;
47 3
        }
48
49 3
        $children[] = $this->selectionSet;
50
51 3
        return $children;
52
    }
53
}
54