ClassPropertyDefinition::isPrimitive()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\Transfer\Definition;
6
7
class ClassPropertyDefinition implements ClassPropertyDefinitionInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $name;
13
14
    /**
15
     * @var string
16
     */
17
    protected $type;
18
19
    /**
20
     * @var string|null
21
     */
22
    protected $typeAlias;
23
24
    /**
25
     * @var string|null
26
     */
27
    protected $typeNamespace;
28
29
    /**
30
     * @var string|null
31
     */
32
    protected $singular;
33
34
    /**
35
     * @var bool
36
     */
37
    protected $isNullable;
38
39
    /**
40
     * @var bool|null
41
     */
42
    protected $isArray;
43
44
    /**
45
     * @return string
46
     */
47
    public function getName(): string
48
    {
49
        return $this->name;
50
    }
51
52
    /**
53
     * @param string $name
54
     *
55
     * @return \Jellyfish\Transfer\Definition\ClassPropertyDefinitionInterface
56
     */
57
    public function setName(string $name): ClassPropertyDefinitionInterface
58
    {
59
        $this->name = $name;
60
61
        return $this;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getType(): string
68
    {
69
        return $this->type;
70
    }
71
72
    /**
73
     * @param string $type
74
     *
75
     * @return \Jellyfish\Transfer\Definition\ClassPropertyDefinitionInterface
76
     */
77
    public function setType(string $type): ClassPropertyDefinitionInterface
78
    {
79
        $this->type = $type;
80
81
        return $this;
82
    }
83
84
    /**
85
     * @return string|null
86
     */
87
    public function getTypeAlias(): ?string
88
    {
89
        return $this->typeAlias;
90
    }
91
92
    /**
93
     * @param string|null $typeAlias
94
     *
95
     * @return \Jellyfish\Transfer\Definition\ClassPropertyDefinitionInterface
96
     */
97
    public function setTypeAlias(?string $typeAlias): ClassPropertyDefinitionInterface
98
    {
99
        $this->typeAlias = $typeAlias;
100
101
        return $this;
102
    }
103
104
    /**
105
     * @return string|null
106
     */
107
    public function getTypeNamespace(): ?string
108
    {
109
        return $this->typeNamespace;
110
    }
111
112
    /**
113
     * @param string|null $typeNamespace
114
     *
115
     * @return \Jellyfish\Transfer\Definition\ClassPropertyDefinitionInterface
116
     */
117
    public function setTypeNamespace(?string $typeNamespace): ClassPropertyDefinitionInterface
118
    {
119
        $this->typeNamespace = $typeNamespace;
120
121
        return $this;
122
    }
123
124
    /**
125
     * @return string|null
126
     */
127
    public function getSingular(): ?string
128
    {
129
        return $this->singular;
130
    }
131
132
    /**
133
     * @param string|null $singular
134
     *
135
     * @return \Jellyfish\Transfer\Definition\ClassPropertyDefinitionInterface
136
     */
137
    public function setSingular(?string $singular): ClassPropertyDefinitionInterface
138
    {
139
        $this->singular = $singular;
140
141
        return $this;
142
    }
143
144
    /**
145
     * @return bool
146
     */
147
    public function isNullable(): bool
148
    {
149
        return $this->isNullable;
150
    }
151
152
    /**
153
     * @param bool $isNullable
154
     *
155
     * @return \Jellyfish\Transfer\Definition\ClassPropertyDefinitionInterface
156
     */
157
    public function setIsNullable(bool $isNullable): ClassPropertyDefinitionInterface
158
    {
159
        $this->isNullable = $isNullable;
160
161
        return $this;
162
    }
163
164
    /**
165
     * @return bool
166
     */
167
    public function isPrimitive(): bool
168
    {
169
        return \preg_match('/^(int|float|string|bool(ean)?)$/', $this->type) === 1;
170
    }
171
172
    /**
173
     * @return bool
174
     */
175
    public function isArray(): bool
176
    {
177
        return $this->isArray === true;
178
    }
179
180
    /**
181
     * @param bool|null $isArray
182
     *
183
     * @return \Jellyfish\Transfer\Definition\ClassPropertyDefinitionInterface
184
     */
185
    public function setIsArray(?bool $isArray): ClassPropertyDefinitionInterface
186
    {
187
        $this->isArray = $isArray;
188
189
        return $this;
190
    }
191
}
192