Definition   A
last analyzed

Complexity

Total Complexity 23

Size/Duplication

Total Lines 307
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 7
Bugs 2 Features 0
Metric Value
wmc 23
c 7
b 2
f 0
lcom 2
cbo 2
dl 0
loc 307
rs 10

23 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __toString() 0 4 1
A getId() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A setDescription() 0 6 1
A getDescription() 0 4 1
A setType() 0 6 1
A getType() 0 4 1
A setUnit() 0 6 1
A getUnit() 0 4 1
A setRequired() 0 6 1
A getRequired() 0 4 1
A setOrderIndex() 0 6 1
A getOrderIndex() 0 4 1
A setSchema() 0 6 1
A getSchema() 0 4 1
A addOption() 0 7 1
A removeOption() 0 4 1
A getOptions() 0 4 1
A addAttribute() 0 6 1
A removeAttribute() 0 4 1
A getAttributes() 0 4 1
1
<?php
2
3
namespace Padam87\AttributeBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
8
/**
9
 * @ORM\Entity
10
 * @ORM\Table(name="attribute_definition")
11
 */
12
class Definition
13
{
14
    /**
15
     * @var int
16
     *
17
     * @ORM\Id
18
     * @ORM\Column(type="integer")
19
     * @ORM\GeneratedValue(strategy="AUTO")
20
     */
21
    private $id;
22
23
    /**
24
     * @var string
25
     *
26
     * @ORM\Column(type="string", length=255)
27
     */
28
    private $name;
29
30
    /**
31
     * @var string
32
     *
33
     * @ORM\Column(type="text", nullable=true)
34
     */
35
    private $description;
36
37
    /**
38
     * @var string
39
     *
40
     * @ORM\Column(type="string", length=100)
41
     */
42
    private $type;
43
44
    /**
45
     * @var string
46
     *
47
     * @ORM\Column(type="string", length=255, nullable=true)
48
     */
49
    private $unit;
50
51
    /**
52
     * @var boolean
53
     *
54
     * @ORM\Column(type="boolean")
55
     */
56
    private $required = false;
57
58
    /**
59
     * @var string
60
     *
61
     * @ORM\Column(type="integer", nullable=true)
62
     */
63
    private $orderIndex;
64
65
    /**
66
     * @var Schema
67
     *
68
     * @ORM\ManyToOne(targetEntity="Schema", inversedBy="definitions")
69
     * @ORM\JoinColumn(name="schema_id", referencedColumnName="id")
70
     */
71
    private $schema;
72
73
    /**
74
     * @var ArrayCollection
75
     *
76
     * @ORM\OneToMany(
77
     *     targetEntity="Option",
78
     *     mappedBy="definition",
79
     *     orphanRemoval=true,
80
     *     cascade={"persist", "remove"},
81
     *     fetch="EXTRA_LAZY"
82
     * )
83
     * @ORM\OrderBy({"id" = "ASC"})
84
     */
85
    private $options;
86
87
    /**
88
     * @var Attribute
89
     *
90
     * @ORM\OneToMany(
91
     *     targetEntity="\Padam87\AttributeBundle\Entity\Attribute",
92
     *     mappedBy="definition",
93
     *     cascade={"remove"}
94
     * )
95
     */
96
    private $attributes;
97
98
    public function __construct()
99
    {
100
        $this->options = new ArrayCollection();
101
        $this->attributes = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<Padam87\AttributeBundle\Entity\Attribute> of property $attributes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
102
    }
103
104
    /**
105
     * @return mixed
106
     */
107
    public function __toString()
108
    {
109
        return $this->name;
110
    }
111
112
    /**
113
     * @return integer
114
     */
115
    public function getId()
116
    {
117
        return $this->id;
118
    }
119
120
    /**
121
     * @param string $name
122
     *
123
     * @return $this
124
     */
125
    public function setName($name)
126
    {
127
        $this->name = $name;
128
129
        return $this;
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getName()
136
    {
137
        return $this->name;
138
    }
139
140
    /**
141
     * @param string $description
142
     *
143
     * @return $this
144
     */
145
    public function setDescription($description)
146
    {
147
        $this->description = $description;
148
149
        return $this;
150
    }
151
152
    /**
153
     * @return string
154
     */
155
    public function getDescription()
156
    {
157
        return $this->description;
158
    }
159
160
    /**
161
     * @param string $type
162
     *
163
     * @return $this
164
     */
165
    public function setType($type)
166
    {
167
        $this->type = $type;
168
169
        return $this;
170
    }
171
172
    /**
173
     * @return string
174
     */
175
    public function getType()
176
    {
177
        return $this->type;
178
    }
179
180
    /**
181
     * @param string $unit
182
     *
183
     * @return $this
184
     */
185
    public function setUnit($unit)
186
    {
187
        $this->unit = $unit;
188
189
        return $this;
190
    }
191
192
    /**
193
     * @return string
194
     */
195
    public function getUnit()
196
    {
197
        return $this->unit;
198
    }
199
200
    /**
201
     * @param boolean $required
202
     *
203
     * @return $this
204
     */
205
    public function setRequired($required)
206
    {
207
        $this->required = $required;
208
209
        return $this;
210
    }
211
212
    /**
213
     * @return boolean
214
     */
215
    public function getRequired()
216
    {
217
        return $this->required;
218
    }
219
220
    /**
221
     * @param integer $orderIndex
222
     *
223
     * @return $this
224
     */
225
    public function setOrderIndex($orderIndex)
226
    {
227
        $this->orderIndex = $orderIndex;
0 ignored issues
show
Documentation Bug introduced by
The property $orderIndex was declared of type string, but $orderIndex is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
228
229
        return $this;
230
    }
231
232
    /**
233
     * @return integer
234
     */
235
    public function getOrderIndex()
236
    {
237
        return $this->orderIndex;
238
    }
239
240
    /**
241
     * @param Schema $schema
242
     *
243
     * @return $this
244
     */
245
    public function setSchema(Schema $schema = null)
246
    {
247
        $this->schema = $schema;
248
249
        return $this;
250
    }
251
252
    /**
253
     * Get schema
254
     *
255
     * @return Schema
256
     */
257
    public function getSchema()
258
    {
259
        return $this->schema;
260
    }
261
262
    /**
263
     * @param Option $option
264
     *
265
     * @return $this
266
     */
267
    public function addOption(Option $option)
268
    {
269
        $this->options[] = $option;
270
        $option->setDefinition($this);
271
272
        return $this;
273
    }
274
275
    /**
276
     * @param Option $options
277
     */
278
    public function removeOption(Option $options)
279
    {
280
        $this->options->removeElement($options);
281
    }
282
283
    /**
284
     * @return ArrayCollection
285
     */
286
    public function getOptions()
287
    {
288
        return $this->options;
289
    }
290
291
    /**
292
     * @param Attribute $attributes
293
     *
294
     * @return $this
295
     */
296
    public function addAttribute(Attribute $attributes)
297
    {
298
        $this->attributes[] = $attributes;
299
300
        return $this;
301
    }
302
303
    /**
304
     * @param Attribute $attributes
305
     */
306
    public function removeAttribute(Attribute $attributes)
307
    {
308
        $this->attributes->removeElement($attributes);
0 ignored issues
show
Bug introduced by
The method removeElement() does not seem to exist on object<Padam87\AttributeBundle\Entity\Attribute>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
309
    }
310
311
    /**
312
     * @return ArrayCollection
313
     */
314
    public function getAttributes()
315
    {
316
        return $this->attributes;
317
    }
318
}
319