OperationBase   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 45
loc 45
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 2
A getChildren() 16 16 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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