Completed
Push — master ( 334f6b...01d482 )
by Adrien
11:34
created

Booking::setDestination()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Model;
6
7
use Application\DBAL\Types\BookingStatusType;
8
use Cake\Chronos\Chronos;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\Common\Collections\Collection;
11
use Doctrine\ORM\Mapping as ORM;
12
use GraphQL\Doctrine\Annotation as API;
13
14
/**
15
 * A booking linking a user and several bookables
16
 *
17
 * @ORM\Entity(repositoryClass="Application\Repository\BookingRepository")
18
 */
19
class Booking extends AbstractModel
20
{
21
    /**
22
     * @var string
23
     *
24
     * @ORM\Column(type="BookingStatus", length=10, options={"default" = BookingStatusType::APPLICATION})
25
     */
26
    private $status = BookingStatusType::APPLICATION;
27
28
    /**
29
     * @var int
30
     * @ORM\Column(type="integer", options={"unsigned" = true, "default" = 1})
31
     */
32
    private $participantCount = 1;
33
34
    /**
35
     * @var string
36
     *
37
     * @ORM\Column(type="string", length=50, options={"default" = ""})
38
     */
39
    private $destination = '';
40
41
    /**
42
     * @var string
43
     *
44
     * @ORM\Column(type="text", length=65535, options={"default" = ""})
45
     */
46
    private $startComment = '';
47
48
    /**
49
     * @var string
50
     *
51
     * @ORM\Column(type="text", length=65535, options={"default" = ""})
52
     */
53
    private $endComment = '';
54
55
    /**
56
     * @var Chronos
57
     *
58
     * @ORM\Column(type="datetime")
59
     */
60
    private $startDate;
61
62
    /**
63
     * @var Chronos
64
     *
65
     * @ORM\Column(type="datetime", nullable=true)
66
     */
67
    private $endDate;
68
69
    /**
70
     * @var string
71
     *
72
     * @ORM\Column(type="string", length=50, options={"default" = ""})
73
     */
74
    private $estimatedEndDate = '';
75
76
    /**
77
     * @var User
78
     *
79
     * @ORM\ManyToOne(targetEntity="Application\Model\User", inversedBy="bookings")
80
     * @ORM\JoinColumns({
81
     *     @ORM\JoinColumn(onDelete="SET NULL")
82
     * })
83
     */
84
    private $responsible;
85
86
    /**
87
     * @var Collection
88
     *
89
     * @ORM\ManyToMany(targetEntity="Bookable", inversedBy="bookings")
90
     */
91
    private $bookables;
92
93
    /**
94
     * Constructor
95
     */
96
    public function __construct()
97
    {
98
        $this->bookables = new ArrayCollection();
99
    }
100
101
    /**
102
     * Set responsible
103
     *
104
     * @param null|User $responsible
105
     */
106
    public function setResponsible(?User $responsible): void
107
    {
108
        $this->responsible = $responsible;
109
        $this->responsible->bookingAdded($this);
0 ignored issues
show
Bug introduced by
The method bookingAdded() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

109
        $this->responsible->/** @scrutinizer ignore-call */ 
110
                            bookingAdded($this);

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...
110
    }
111
112
    /**
113
     * Get responsible
114
     *
115
     * @return null|User
116
     */
117
    public function getResponsible(): ?User
118
    {
119
        return $this->responsible;
120
    }
121
122
    /**
123
     * Total count of participant, at least 1.
124
     *
125
     * @return int
126
     */
127
    public function getParticipantCount(): int
128
    {
129
        return $this->participantCount;
130
    }
131
132
    /**
133
     * @param int $participantCount
134
     */
135
    public function setParticipantCount(int $participantCount): void
136
    {
137
        $this->participantCount = $participantCount;
138
    }
139
140
    /**
141
     * @return string
142
     */
143
    public function getDestination(): string
144
    {
145
        return $this->destination;
146
    }
147
148
    /**
149
     * @param string $destination
150
     */
151
    public function setDestination(string $destination): void
152
    {
153
        $this->destination = $destination;
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function getStartComment(): string
160
    {
161
        return $this->startComment;
162
    }
163
164
    /**
165
     * @param string $startComment
166
     */
167
    public function setStartComment(string $startComment): void
168
    {
169
        $this->startComment = $startComment;
170
    }
171
172
    /**
173
     * @return string
174
     */
175
    public function getEndComment(): string
176
    {
177
        return $this->endComment;
178
    }
179
180
    /**
181
     * @param string $endComment
182
     */
183
    public function setEndComment(string $endComment): void
184
    {
185
        $this->endComment = $endComment;
186
    }
187
188
    /**
189
     * @return Chronos
190
     */
191
    public function getStartDate(): Chronos
192
    {
193
        return $this->startDate;
194
    }
195
196
    /**
197
     * @param Chronos $startDate
198
     */
199
    public function setStartDate(Chronos $startDate): void
200
    {
201
        $this->startDate = $startDate;
202
    }
203
204
    /**
205
     * @return null|Chronos
206
     */
207
    public function getEndDate(): ?Chronos
208
    {
209
        return $this->endDate;
210
    }
211
212
    /**
213
     * @param Chronos $endDate
214
     */
215
    public function setEndDate(Chronos $endDate): void
216
    {
217
        $this->endDate = $endDate;
218
    }
219
220
    /**
221
     * @return string
222
     */
223
    public function getEstimatedEndDate(): string
224
    {
225
        return $this->estimatedEndDate;
226
    }
227
228
    /**
229
     * @param string $estimatedEndDate
230
     */
231
    public function setEstimatedEndDate(string $estimatedEndDate): void
232
    {
233
        $this->estimatedEndDate = $estimatedEndDate;
234
    }
235
236
    /**
237
     * @return Collection
238
     */
239
    public function getBookables(): Collection
240
    {
241
        return $this->bookables;
242
    }
243
244
    /**
245
     * Add bookable
246
     *
247
     * @param Bookable $bookable
248
     */
249
    public function addBookable(Bookable $bookable): void
250
    {
251
        if (!$this->bookables->contains($bookable)) {
252
            $this->bookables->add($bookable);
253
        }
254
    }
255
256
    /**
257
     * @API\Field(type="BookingStatus")
258
     *
259
     * @return string
260
     */
261
    public function getStatus(): string
262
    {
263
        return $this->status;
264
    }
265
266
    /**
267
     * @API\Input(type="BookingStatus")
268
     *
269
     * @param string $status
270
     */
271
    public function setStatus(string $status): void
272
    {
273
        $this->status = $status;
274
    }
275
}
276