Passed
Push — master ( 0978b6...645268 )
by Valery
03:37
created

Property::getBathroomsNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Entity;
6
7
use App\Entity\Traits\EntityIdTrait;
8
use App\Entity\Traits\EntityLocationTrait;
9
use App\Entity\Traits\EntityMetaTrait;
10
use App\Entity\Traits\EntityTimestampableTrait;
11
use Doctrine\Common\Collections\ArrayCollection;
12
use Doctrine\Common\Collections\Collection;
13
use Doctrine\ORM\Mapping as ORM;
14
15
/**
16
 * @ORM\Entity(repositoryClass="App\Repository\PropertyRepository")
17
 */
18
class Property
19
{
20
    use EntityIdTrait;
21
    use EntityMetaTrait;
22
    use EntityTimestampableTrait;
23
    use EntityLocationTrait;
24
25
    /**
26
     * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="properties")
27
     * @ORM\JoinColumn(nullable=false)
28
     */
29
    private $author;
30
31
    /**
32
     * @ORM\ManyToOne(targetEntity="App\Entity\DealType", inversedBy="properties")
33
     * @ORM\JoinColumn(nullable=false)
34
     */
35
    private $deal_type;
36
37
    /**
38
     * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="properties")
39
     * @ORM\JoinColumn(nullable=false)
40
     */
41
    private $category;
42
43
    /**
44
     * @ORM\Column(type="string", length=255)
45
     */
46
    private $title;
47
48
    /**
49
     * @ORM\Column(type="string", length=255, nullable=true)
50
     */
51
    private $slug;
52
53
    /**
54
     * @ORM\Column(type="text")
55
     */
56
    private $content;
57
58
    /**
59
     * @ORM\Column(type="smallint", nullable=true)
60
     */
61
    private $bathrooms_number;
62
63
    /**
64
     * @ORM\Column(type="smallint", nullable=true)
65
     */
66
    private $bedrooms_number;
67
68
    /**
69
     * @ORM\Column(type="smallint", nullable=true)
70
     */
71
    private $max_guests;
72
73
    /**
74
     * @ORM\Column(type="boolean", nullable=true)
75
     */
76
    private $show_map;
77
78
    /**
79
     * @ORM\Column(type="integer", nullable=true)
80
     */
81
    private $price;
82
83
    /**
84
     * @ORM\Column(type="string", length=255, nullable=true)
85
     */
86
    private $price_type;
87
88
    /**
89
     * @ORM\Column(type="boolean", nullable=true)
90
     */
91
    private $available_now;
92
93
    /**
94
     * @ORM\Column(type="string", length=255, options={"default": "pending"})
95
     */
96
    private $state = 'published';
97
98
    /**
99
     * @ORM\OneToMany(targetEntity="App\Entity\Photo", mappedBy="property", orphanRemoval=true)
100
     * @ORM\OrderBy({"sort_order" = "ASC"})
101
     */
102
    private $photos;
103
104
    /**
105
     * @ORM\ManyToMany(targetEntity="App\Entity\Feature", inversedBy="properties")
106
     */
107
    private $features;
108
109
    /**
110
     * @ORM\Column(type="integer")
111
     */
112
    private $priority_number;
113
114
    public function __construct()
115
    {
116
        $this->photos = new ArrayCollection();
117
        $this->features = new ArrayCollection();
118
    }
119
120
    public function getAuthor(): ?User
121
    {
122
        return $this->author;
123
    }
124
125
    public function setAuthor(?User $author): self
126
    {
127
        $this->author = $author;
128
129
        return $this;
130
    }
131
132
    public function getDealType(): ?DealType
133
    {
134
        return $this->deal_type;
135
    }
136
137
    public function setDealType(?DealType $dealType): self
138
    {
139
        $this->deal_type = $dealType;
140
141
        return $this;
142
    }
143
144
    public function getCategory(): ?Category
145
    {
146
        return $this->category;
147
    }
148
149
    public function setCategory(?Category $category): self
150
    {
151
        $this->category = $category;
152
153
        return $this;
154
    }
155
156
    public function getTitle(): ?string
157
    {
158
        return $this->title;
159
    }
160
161
    public function setTitle(string $title): self
162
    {
163
        $this->title = $title;
164
165
        return $this;
166
    }
167
168
    public function getSlug(): ?string
169
    {
170
        return $this->slug;
171
    }
172
173
    public function setSlug(string $slug): self
174
    {
175
        $this->slug = $slug;
176
177
        return $this;
178
    }
179
180
    public function getContent(): ?string
181
    {
182
        return $this->content;
183
    }
184
185
    public function setContent(string $content): self
186
    {
187
        $this->content = $content;
188
189
        return $this;
190
    }
191
192
    public function getBathroomsNumber(): ?int
193
    {
194
        return $this->bathrooms_number;
195
    }
196
197
    public function setBathroomsNumber(?int $bathrooms_number): self
198
    {
199
        $this->bathrooms_number = $bathrooms_number;
200
201
        return $this;
202
    }
203
204
    public function getBedroomsNumber(): ?int
205
    {
206
        return $this->bedrooms_number;
207
    }
208
209
    public function setBedroomsNumber(?int $bedrooms_number): self
210
    {
211
        $this->bedrooms_number = $bedrooms_number;
212
213
        return $this;
214
    }
215
216
    public function getShowMap(): ?bool
217
    {
218
        return $this->show_map;
219
    }
220
221
    public function setShowMap(?bool $show_map): self
222
    {
223
        $this->show_map = $show_map;
224
225
        return $this;
226
    }
227
228
    public function getPrice(): ?int
229
    {
230
        return $this->price;
231
    }
232
233
    public function setPrice(?int $price): self
234
    {
235
        $this->price = $price;
236
237
        return $this;
238
    }
239
240
    public function getPriceType(): ?string
241
    {
242
        return $this->price_type;
243
    }
244
245
    public function setPriceType(?string $price_type): self
246
    {
247
        $this->price_type = $price_type;
248
249
        return $this;
250
    }
251
252
    public function getAvailableNow(): ?bool
253
    {
254
        return $this->available_now;
255
    }
256
257
    public function setAvailableNow(?bool $available_now): self
258
    {
259
        $this->available_now = $available_now;
260
261
        return $this;
262
    }
263
264
    public function getPhotos(): Collection
265
    {
266
        return $this->photos;
267
    }
268
269
    public function addPhoto(Photo $photo): self
270
    {
271
        if (!$this->photos->contains($photo)) {
272
            $this->photos[] = $photo;
273
            $photo->setProperty($this);
274
        }
275
276
        return $this;
277
    }
278
279
    public function removePhoto(Photo $photo): self
280
    {
281
        if ($this->photos->contains($photo)) {
282
            $this->photos->removeElement($photo);
283
            // set the owning side to null (unless already changed)
284
            if ($photo->getProperty() === $this) {
285
                $photo->setProperty(null);
286
            }
287
        }
288
289
        return $this;
290
    }
291
292
    public function getFeatures(): Collection
293
    {
294
        return $this->features;
295
    }
296
297
    public function addFeature(Feature $feature): self
298
    {
299
        if (!$this->features->contains($feature)) {
300
            $this->features[] = $feature;
301
        }
302
303
        return $this;
304
    }
305
306
    public function removeFeature(Feature $feature): self
307
    {
308
        if ($this->features->contains($feature)) {
309
            $this->features->removeElement($feature);
310
        }
311
312
        return $this;
313
    }
314
315
    public function getPriorityNumber(): ?int
316
    {
317
        return $this->priority_number;
318
    }
319
320
    public function setPriorityNumber(?int $priority_number): self
321
    {
322
        $this->priority_number = $priority_number;
323
324
        return $this;
325
    }
326
327
    public function getMaxGuests(): ?int
328
    {
329
        return $this->max_guests;
330
    }
331
332
    public function setMaxGuests(?int $max_guests): self
333
    {
334
        $this->max_guests = $max_guests;
335
336
        return $this;
337
    }
338
339
    public function getState(): ?string
340
    {
341
        return $this->state;
342
    }
343
344
    public function setState(string $state): self
345
    {
346
        $this->state = $state;
347
348
        return $this;
349
    }
350
351
    public function isPublished(): bool
352
    {
353
        return 'published' === $this->state;
354
    }
355
}
356