Code Duplication    Length = 45-49 lines in 2 locations

src/Query/OperationBase.php 1 location

@@ 5-49 (lines=45) @@
2
3
namespace HansOtt\GraphQL\Query;
4
5
abstract class OperationBase extends NodeBase implements Operation
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
    public function __construct(
20
        $name = null,
21
        array $variables = array(),
22
        $directives = array(),
23
        SelectionSet $selectionSet,
24
        Location $location = null
25
    ) {
26
        parent::__construct($location);
27
        $this->name = $name ? (string) $name : null;
28
        $this->variables = $variables;
29
        $this->directives = $directives;
30
        $this->selectionSet = $selectionSet;
31
    }
32
33
    final public function getChildren()
34
    {
35
        $children = array();
36
37
        foreach ($this->variables as $variable) {
38
            $children[] = $variable;
39
        }
40
41
        foreach ($this->directives as $directive) {
42
            $children[] = $directive;
43
        }
44
45
        $children[] = $this->selectionSet;
46
47
        return $children;
48
    }
49
}
50

src/Query/SelectionField.php 1 location

@@ 5-53 (lines=49) @@
2
3
namespace HansOtt\GraphQL\Query;
4
5
final class SelectionField extends NodeBase implements Selection
6
{
7
    public $name;
8
    public $alias;
9
    public $arguments;
10
    public $directives;
11
    public $selectionSet;
12
13
    /**
14
     * @param string|null $alias
15
     * @param string $name
16
     * @param Argument[] $arguments
17
     * @param Directive[] $directives
18
     * @param SelectionSet|null $selectionSet
19
     * @param Location|null $location
20
     */
21
    public function __construct(
22
        $alias = null,
23
        $name,
24
        array $arguments = array(),
25
        array $directives = array(),
26
        SelectionSet $selectionSet = null,
27
        Location $location = null
28
    ) {
29
        parent::__construct($location);
30
        $this->alias = $alias ? (string) $alias : null;
31
        $this->name = (string) $name;
32
        $this->arguments = $arguments;
33
        $this->directives = $directives;
34
        $this->selectionSet = $selectionSet;
35
    }
36
37
    public function getChildren()
38
    {
39
        $children = array();
40
41
        foreach ($this->arguments as $variable) {
42
            $children[] = $variable;
43
        }
44
45
        foreach ($this->directives as $directive) {
46
            $children[] = $directive;
47
        }
48
49
        $children[] = $this->selectionSet;
50
51
        return $children;
52
    }
53
}
54