OperationBase::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 11

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 5
crap 2
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