FieldArgument::getDefaultValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Fubhy\GraphQL\Type\Definition;
4
5 View Code Duplication
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 159
    public function __construct(array $config)
33
    {
34 159
        $this->name = $config['name'];
35 159
        $this->type = $config['type'];
36 159
        $this->description = isset($config['description']) ? $config['description'] : NULL;
37
38 159
        if (isset($config['defaultValue'])) {
39 3
            $this->defaultValue = $config['defaultValue'];
40 3
        }
41 159
    }
42
43
    /**
44
     * @return string
45
     */
46 165
    public function getName()
47
    {
48 165
        return $this->name;
49
    }
50
51
    /**
52
     * @return string|null
53
     */
54 3
    public function getDescription()
55
    {
56 3
        return $this->description;
57
    }
58
59
    /**
60
     * @return \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface
61
     */
62 207
    public function getType()
63
    {
64 207
        if (is_callable($this->type)) {
65
            return call_user_func($this->type);
66
        }
67
68 207
        return $this->type;
69
    }
70
71
    /**
72
     * @return mixed|null
73
     */
74 6
    public function getDefaultValue()
75
    {
76 6
        return $this->defaultValue;
77
    }
78
}
79