OperationBase::getChildren()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 3.009

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 9
cts 10
cp 0.9
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 4
nop 0
crap 3.009
1
<?php
2
3
namespace HansOtt\GraphQL\Query;
4
5 View Code Duplication
abstract class OperationBase extends NodeBase implements Operation
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 $variables;
9
    public $directives;
10
    public $selectionSet;
11
12
    /**
13
     * @param string|null $name
14
     * @param VariableDefinition[] $variables
15
     * @param Directive[] $directives
16
     * @param SelectionSet $selectionSet
17
     * @param Location|null $location
18
     */
19 48
    public function __construct(
20
        $name = null,
21
        array $variables = array(),
22
        $directives = array(),
23
        SelectionSet $selectionSet,
24
        Location $location = null
25
    ) {
26 48
        parent::__construct($location);
27 48
        $this->name = $name ? (string) $name : null;
28 48
        $this->variables = $variables;
29 48
        $this->directives = $directives;
30 48
        $this->selectionSet = $selectionSet;
31 48
    }
32
33 3
    final public function getChildren()
34
    {
35 3
        $children = array();
36
37 3
        foreach ($this->variables as $variable) {
38 3
            $children[] = $variable;
39 3
        }
40
41 3
        foreach ($this->directives as $directive) {
42
            $children[] = $directive;
43 3
        }
44
45 3
        $children[] = $this->selectionSet;
46
47 3
        return $children;
48
    }
49
}
50