Code Duplication    Length = 71-74 lines in 2 locations

src/Type/Definition/FieldArgument.php 1 location

@@ 5-78 (lines=74) @@
2
3
namespace Fubhy\GraphQL\Type\Definition;
4
5
class FieldArgument
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $name;
11
12
    /**
13
     * @var string|null
14
     */
15
    protected $description;
16
17
    /**
18
     * @var \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface|callable
19
     */
20
    protected $type;
21
22
    /**
23
     * @var mixed
24
     */
25
    protected $defaultValue;
26
27
    /**
28
     * Constructor.
29
     *
30
     * @param array $config
31
     */
32
    public function __construct(array $config)
33
    {
34
        $this->name = $config['name'];
35
        $this->type = $config['type'];
36
        $this->description = isset($config['description']) ? $config['description'] : NULL;
37
38
        if (isset($config['defaultValue'])) {
39
            $this->defaultValue = $config['defaultValue'];
40
        }
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getName()
47
    {
48
        return $this->name;
49
    }
50
51
    /**
52
     * @return string|null
53
     */
54
    public function getDescription()
55
    {
56
        return $this->description;
57
    }
58
59
    /**
60
     * @return \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface
61
     */
62
    public function getType()
63
    {
64
        if (is_callable($this->type)) {
65
            return call_user_func($this->type);
66
        }
67
68
        return $this->type;
69
    }
70
71
    /**
72
     * @return mixed|null
73
     */
74
    public function getDefaultValue()
75
    {
76
        return $this->defaultValue;
77
    }
78
}
79

src/Type/Definition/InputObjectField.php 1 location

@@ 5-75 (lines=71) @@
2
3
namespace Fubhy\GraphQL\Type\Definition;
4
5
class InputObjectField
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $name;
11
12
    /**
13
     * @var \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface|callable
14
     */
15
    protected $type;
16
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $defaultValue;
21
22
    /**
23
     * @var string|null
24
     */
25
    protected $description;
26
27
    /**
28
     * Constructor.
29
     *
30
     * @param array $config
31
     */
32
    public function __construct(array $config)
33
    {
34
        $this->name = $config['name'];
35
        $this->type = $config['type'];
36
        $this->description = isset($config['description']) ? $config['description'] : NULL;
37
        $this->defaultValue = isset($config['defaultValue']) ? $config['defaultValue'] : NULL;
38
    }
39
40
    /**
41
     * @return \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface
42
     */
43
    public function getType()
44
    {
45
        if (is_callable($this->type)) {
46
            return call_user_func($this->type);
47
        }
48
49
        return $this->type;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getName()
56
    {
57
        return $this->name;
58
    }
59
60
    /**
61
     * @return string|null
62
     */
63
    public function getDescription()
64
    {
65
        return $this->description;
66
    }
67
68
    /**
69
     * @return mixed|null
70
     */
71
    public function getDefaultValue()
72
    {
73
        return $this->defaultValue;
74
    }
75
}
76