Completed
Push — master ( 8e51ac...186982 )
by Rafael
03:50
created

ArgumentDefinition::setDefaultValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Definition;
12
13
use Ynlo\GraphQLBundle\Definition\Traits\DefinitionTrait;
14
15
/**
16
 * Class ArgumentDefinition
17
 */
18
class ArgumentDefinition implements DefinitionInterface
19
{
20
    use DefinitionTrait;
21
22
    /**
23
     * @var string
24
     */
25
    protected $type;
26
27
    /**
28
     * @var bool
29
     */
30
    protected $nonNull = true;
31
32
    /**
33
     * @var bool
34
     */
35
    protected $list = false;
36
37
    /**
38
     * @var bool
39
     */
40
    protected $nonNullList = false;
41
42
    /**
43
     * @var string
44
     */
45
    protected $defaultValue;
46
47
    /**
48
     * Use when public argument name does not match with method name
49
     * e.g. userId (public) => $id (method), commonly used for reusable resolvers
50
     *
51
     * @var string
52
     */
53
    protected $internalName;
54
55
    /**
56
     * @return string
57
     */
58
    public function getType(): string
59
    {
60
        return $this->type;
61
    }
62
63
    /**
64
     * @param string $type
65
     *
66
     * @return ArgumentDefinition
67
     */
68
    public function setType(string $type): ArgumentDefinition
69
    {
70
        $this->type = $type;
71
72
        return $this;
73
    }
74
75
    /**
76
     * @return bool
77
     */
78
    public function isNonNull(): bool
79
    {
80
        return $this->nonNull;
81
    }
82
83
    /**
84
     * @param bool $nonNull
85
     *
86
     * @return ArgumentDefinition
87
     */
88
    public function setNonNull(bool $nonNull): ArgumentDefinition
89
    {
90
        $this->nonNull = $nonNull;
91
92
        return $this;
93
    }
94
95
    /**
96
     * @return bool
97
     */
98
    public function isList(): bool
99
    {
100
        return $this->list;
101
    }
102
103
    /**
104
     * @param bool $list
105
     *
106
     * @return ArgumentDefinition
107
     */
108
    public function setList(bool $list): ArgumentDefinition
109
    {
110
        $this->list = $list;
111
112
        return $this;
113
    }
114
115
    /**
116
     * @return bool
117
     */
118
    public function isNonNullList(): bool
119
    {
120
        return $this->nonNullList;
121
    }
122
123
    /**
124
     * @param bool $nonNullList
125
     */
126
    public function setNonNullList(bool $nonNullList)
127
    {
128
        $this->nonNullList = $nonNullList;
129
    }
130
131
    /**
132
     * @return mixed
133
     */
134
    public function getDefaultValue()
135
    {
136
        return $this->defaultValue;
137
    }
138
139
    /**
140
     * @param mixed $defaultValue
141
     *
142
     * @return ArgumentDefinition
143
     */
144
    public function setDefaultValue($defaultValue): ArgumentDefinition
145
    {
146
        $this->defaultValue = $defaultValue;
147
148
        return $this;
149
    }
150
151
    /**
152
     * @return string
153
     */
154
    public function getInternalName(): ?string
155
    {
156
        return $this->internalName ?? $this->name;
157
    }
158
159
    /**
160
     * @param string $internalName
161
     *
162
     * @return ArgumentDefinition
163
     */
164
    public function setInternalName(?string $internalName): ArgumentDefinition
165
    {
166
        $this->internalName = $internalName;
167
168
        return $this;
169
    }
170
}
171