Fragment   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 41
loc 41
ccs 7
cts 14
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 1
A getChildren() 12 12 2

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
final class Fragment extends NodeBase implements Definition
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 $typeCondition;
9
    public $directives;
10
    public $selectionSet;
11
12
    /**
13
     * @param string $name
14
     * @param TypeCondition $typeCondition
15
     * @param Directive[] $directives
16
     * @param SelectionSet $selectionSet
17
     * @param Location|null $location
18
     */
19 3
    public function __construct(
20
        $name,
21
        TypeCondition $typeCondition,
22
        array $directives = array(),
23
        SelectionSet $selectionSet,
24
        Location $location = null
25
    ) {
26 3
        parent::__construct($location);
27 3
        $this->name = (string) $name;
28 3
        $this->typeCondition = $typeCondition;
29 3
        $this->directives = $directives;
30 3
        $this->selectionSet = $selectionSet;
31 3
    }
32
33
    public function getChildren()
34
    {
35
        $children = array($this->typeCondition);
36
37
        foreach ($this->directives as $directive) {
38
            $children[] = $directive;
39
        }
40
41
        $children[] = $this->selectionSet;
42
43
        return $children;
44
    }
45
}
46