Completed
Push — master ( 993468...5fd9a9 )
by Markus
12s queued 10s
created

ClassPropertyDefinition::setTypeNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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