Failed Conditions
Push — master ( 47998f...c62f8a )
by Sam
06:13
created

Bookable::bookableTagRemoved()   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 2
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\BookingTypeType;
8
use Application\Traits\HasCode;
9
use Application\Traits\HasDescription;
10
use Application\Traits\HasName;
11
use Application\Traits\HasRemarks;
12
use Doctrine\Common\Collections\ArrayCollection;
13
use Doctrine\Common\Collections\Collection;
14
use Doctrine\ORM\Mapping as ORM;
15
use GraphQL\Doctrine\Annotation as API;
16
17
/**
18
 * An item that can be booked by a user
19
 *
20
 * @ORM\Entity(repositoryClass="Application\Repository\BookableRepository")
21
 */
22
class Bookable extends AbstractModel
23
{
24
    use HasName;
25
    use HasDescription;
26
    use HasCode;
27
    use HasRemarks;
28
29
    /**
30
     * @var string
31
     *
32
     * @ORM\Column(type="decimal", length=10, options={"default" = "0"})
33
     */
34
    private $initialPrice = '0.00';
35
36
    /**
37
     * @var string
38
     *
39
     * @ORM\Column(type="decimal", length=10, options={"default" = "0"})
40
     */
41
    private $periodicPrice = '0.00';
42
43
    /**
44
     * @var int
45
     *
46
     * @ORM\Column(type="smallint", options={"unsigned" = true, "default" = "1"})
47
     */
48
    private $simultaneousBookingMaximum = 1;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(type="BookingType", length=10, options={"default" = BookingTypeType::SELF_APPROVED})
54
     */
55
    private $bookingType = BookingTypeType::SELF_APPROVED;
56
57
    /**
58
     * @var BookableTag
59
     *
60
     * @ORM\ManyToMany(targetEntity="BookableTag", mappedBy="bookables")
61
     */
62
    private $bookableTags;
63
64
    /**
65
     * @var Collection
66
     * @ORM\ManyToMany(targetEntity="Booking", mappedBy="bookables")
67
     */
68
    private $bookings;
69
70
    /**
71
     * @var Collection
72
     * @ORM\ManyToMany(targetEntity="License", mappedBy="bookables")
73
     */
74
    private $licenses;
75
76
    /**
77
     * Constructor
78
     */
79 2
    public function __construct()
80
    {
81 2
        $this->bookings = new ArrayCollection();
82 2
        $this->licenses = new ArrayCollection();
83 2
        $this->bookableTags = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new Doctrine\Common\Collections\ArrayCollection() of type Doctrine\Common\Collections\ArrayCollection is incompatible with the declared type Application\Model\BookableTag of property $bookableTags.

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...
84 2
    }
85
86
    /**
87
     * @return Collection
88
     */
89 1
    public function getBookings(): Collection
90
    {
91 1
        return $this->bookings;
92
    }
93
94
    /**
95
     * Notify the bookable that it has a new booking.
96
     * This should only be called by Booking::addBookable()
97
     *
98
     * @param Booking $booking
99
     */
100 1
    public function bookingAdded(Booking $booking): void
101
    {
102 1
        $this->bookings->add($booking);
103 1
    }
104
105
    /**
106
     * Notify the bookable that it a booking was removed.
107
     * This should only be called by Booking::removeBookable()
108
     *
109
     * @param Booking $booking
110
     */
111 1
    public function bookingRemoved(Booking $booking): void
112
    {
113 1
        $this->bookings->removeElement($booking);
114 1
    }
115
116
    /**
117
     * @return Collection
118
     */
119 1
    public function getLicenses(): Collection
120
    {
121 1
        return $this->licenses;
122
    }
123
124
    /**
125
     * Notify the bookable that it has a new license.
126
     * This should only be called by License::addBookable()
127
     *
128
     * @param License $license
129
     */
130 1
    public function licenseAdded(License $license): void
131
    {
132 1
        $this->licenses->add($license);
133 1
    }
134
135
    /**
136
     * Notify the bookable that it a license was removed.
137
     * This should only be called by License::removeBookable()
138
     *
139
     * @param License $license
140
     */
141 1
    public function licenseRemoved(License $license): void
142
    {
143 1
        $this->licenses->removeElement($license);
144 1
    }
145
146
    /**
147
     * @return string
148
     */
149
    public function getInitialPrice(): string
150
    {
151
        return $this->initialPrice;
152
    }
153
154
    /**
155
     * @param string $initialPrice
156
     */
157
    public function setInitialPrice(string $initialPrice): void
158
    {
159
        $this->initialPrice = $initialPrice;
160
    }
161
162
    /**
163
     * @return string
164
     */
165
    public function getPeriodicPrice(): string
166
    {
167
        return $this->periodicPrice;
168
    }
169
170
    /**
171
     * @param string $periodicPrice
172
     */
173
    public function setPeriodicPrice(string $periodicPrice): void
174
    {
175
        $this->periodicPrice = $periodicPrice;
176
    }
177
178
    /**
179
     * @return int
180
     */
181
    public function getSimultaneousBookingMaximum(): int
182
    {
183
        return $this->simultaneousBookingMaximum;
184
    }
185
186
    /**
187
     * @param int $simultaneousBookingMaximum
188
     */
189
    public function setSimultaneousBookingMaximum(int $simultaneousBookingMaximum): void
190
    {
191
        $this->simultaneousBookingMaximum = $simultaneousBookingMaximum;
192
    }
193
194
    /**
195
     * @API\Field(type="BookingType")
196
     *
197
     * @return string
198
     */
199
    public function getBookingType(): string
200
    {
201
        return $this->bookingType;
202
    }
203
204
    /**
205
     * @API\Input(type="BookingType")
206
     *
207
     * @param string $bookingType
208
     */
209
    public function setBookingType(string $bookingType): void
210
    {
211
        $this->bookingType = $bookingType;
212
    }
213
214
    /**
215
     * @return Collection
216
     */
217
    public function getBookableTags(): Collection
218
    {
219
        return $this->bookableTags;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->bookableTags returns the type Application\Model\BookableTag which is incompatible with the type-hinted return Doctrine\Common\Collections\Collection.
Loading history...
220
    }
221
222
    /**
223
     * Notify the user that it has a new bookableTag.
224
     * This should only be called by BookableTag::addUser()
225
     *
226
     * @param BookableTag $bookableTag
227
     */
228
    public function bookableTagAdded(BookableTag $bookableTag): void
229
    {
230
        $this->bookableTags->add($bookableTag);
0 ignored issues
show
Bug introduced by
The method add() does not exist on Application\Model\BookableTag. ( Ignorable by Annotation )

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

230
        $this->bookableTags->/** @scrutinizer ignore-call */ 
231
                             add($bookableTag);

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...
231
    }
232
233
    /**
234
     * Notify the user that it a bookableTag was removed.
235
     * This should only be called by BookableTag::removeUser()
236
     *
237
     * @param BookableTag $bookableTag
238
     */
239
    public function bookableTagRemoved(BookableTag $bookableTag): void
240
    {
241
        $this->bookableTags->removeElement($bookableTag);
0 ignored issues
show
Bug introduced by
The method removeElement() does not exist on Application\Model\BookableTag. ( Ignorable by Annotation )

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

241
        $this->bookableTags->/** @scrutinizer ignore-call */ 
242
                             removeElement($bookableTag);

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...
242
    }
243
}
244