Completed
Push — master ( e13501...8c19ea )
by Alexandr
05:24
created

Variable::isArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Date: 23.11.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Parser\Ast\ArgumentValue;
9
10
class Variable implements ValueInterface
11
{
12
13
    /** @var  string */
14
    private $name;
15
16
    /** @var  mixed */
17
    private $value;
18
19
    /** @var string */
20
    private $type;
21
22
    /** @var bool */
23
    private $nullable = false;
24
25
    /** @var bool */
26
    private $isArray = false;
27
28
    /** @var bool  */
29
    private $used = false;
30
31 10
    public function __construct($name, $type, $nullable = false, $isArray = false)
32
    {
33 10
        $this->name     = $name;
34 10
        $this->type     = $type;
35 10
        $this->isArray  = $isArray;
36 10
        $this->nullable = $nullable;
37 10
    }
38
39
    /**
40
     * @return mixed
41
     *
42
     * @throws \LogicException
43
     */
44 4
    public function getValue()
45
    {
46 4
        if (null === $this->value) {
47 2
            throw new \LogicException('Value is not set for variable "' . $this->name . '"');
48
        }
49
50 2
        return $this->value;
51
    }
52
53
    /**
54
     * @param mixed $value
55
     */
56 3
    public function setValue($value)
57
    {
58 3
        $this->value = $value;
59 3
    }
60
61
    /**
62
     * @return string
63
     */
64 8
    public function getName()
65
    {
66 8
        return $this->name;
67
    }
68
69
    /**
70
     * @param string $name
71
     */
72 1
    public function setName($name)
73
    {
74 1
        $this->name = $name;
75 1
    }
76
77
    /**
78
     * @return string
79
     */
80 5
    public function getTypeName()
81
    {
82 5
        return $this->type;
83
    }
84
85
    /**
86
     * @param string $type
87
     */
88 1
    public function setTypeName($type)
89
    {
90 1
        $this->type = $type;
91 1
    }
92
93
    /**
94
     * @return boolean
95
     */
96 1
    public function isArray()
97
    {
98 1
        return $this->isArray;
99
    }
100
101
    /**
102
     * @param boolean $isArray
103
     */
104 1
    public function setIsArray($isArray)
105
    {
106 1
        $this->isArray = $isArray;
107 1
    }
108
109
    /**
110
     * @return boolean
111
     */
112 1
    public function isNullable()
113
    {
114 1
        return $this->nullable;
115
    }
116
117
    /**
118
     * @param boolean $nullable
119
     */
120 1
    public function setNullable($nullable)
121
    {
122 1
        $this->nullable = $nullable;
123 1
    }
124
125
    /**
126
     * @return boolean
127
     */
128 4
    public function isUsed()
129
    {
130 4
        return $this->used;
131
    }
132
133
    /**
134
     * @param boolean $used
135
     *
136
     * @return $this
137
     */
138 5
    public function setUsed($used)
139
    {
140 5
        $this->used = $used;
141
142 5
        return $this;
143
    }
144
}
145