Code Duplication    Length = 37-41 lines in 2 locations

src/Query/Fragment.php 1 location

@@ 5-45 (lines=41) @@
2
3
namespace HansOtt\GraphQL\Query;
4
5
final class Fragment extends NodeBase implements Definition
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
    public function __construct(
20
        $name,
21
        TypeCondition $typeCondition,
22
        array $directives = array(),
23
        SelectionSet $selectionSet,
24
        Location $location = null
25
    ) {
26
        parent::__construct($location);
27
        $this->name = (string) $name;
28
        $this->typeCondition = $typeCondition;
29
        $this->directives = $directives;
30
        $this->selectionSet = $selectionSet;
31
    }
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

src/Query/SelectionInlineFragment.php 1 location

@@ 5-41 (lines=37) @@
2
3
namespace HansOtt\GraphQL\Query;
4
5
final class SelectionInlineFragment extends NodeBase implements Selection
6
{
7
    public $typeCondition;
8
    public $directives;
9
    public $selectionSet;
10
11
    /**
12
     * @param TypeCondition|null $typeCondition
13
     * @param Directive[] $directives
14
     * @param SelectionSet $selectionSet
15
     * @param Location|null $location
16
     */
17
    public function __construct(
18
        TypeCondition $typeCondition = null,
19
        array $directives = array(),
20
        SelectionSet $selectionSet,
21
        Location $location = null
22
    ) {
23
        parent::__construct($location);
24
        $this->typeCondition = $typeCondition;
25
        $this->directives = $directives;
26
        $this->selectionSet = $selectionSet;
27
    }
28
29
    public function getChildren()
30
    {
31
        $children = array($this->typeCondition);
32
33
        foreach ($this->directives as $directive) {
34
            $children[] = $directive;
35
        }
36
37
        $children[] = $this->selectionSet;
38
39
        return $children;
40
    }
41
}
42