This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @author Rafał Muszyński <[email protected]> |
||
5 | * @copyright 2014 Sourcefabric o.p.s. |
||
6 | * @license http://www.gnu.org/licenses/gpl-3.0.txt |
||
7 | */ |
||
8 | namespace Newscoop\PaywallBundle\Entity; |
||
9 | |||
10 | use Newscoop\Entity\Publication; |
||
11 | use Newscoop\Entity\User; |
||
12 | use Doctrine\Common\Collections\ArrayCollection; |
||
13 | use Doctrine\ORM\Mapping as ORM; |
||
14 | use Newscoop\PaywallBundle\Discount\DiscountableInterface; |
||
15 | |||
16 | /** |
||
17 | * Subscription entity. |
||
18 | * |
||
19 | * @ORM\Entity(repositoryClass="Newscoop\PaywallBundle\Entity\Repository\UserSubscriptionRepository") |
||
20 | * @ORM\Table(name="plugin_paywall_user_subscriptions") |
||
21 | */ |
||
22 | class UserSubscription implements DiscountableInterface, ProlongableItemInterface, PriceableInterface |
||
23 | { |
||
24 | const TYPE_PAID = 'P'; |
||
25 | const TYPE_PAID_NOW = 'PN'; |
||
26 | const TYPE_TRIAL = 'T'; |
||
27 | |||
28 | /** |
||
29 | * @ORM\Id |
||
30 | * @ORM\GeneratedValue |
||
31 | * @ORM\Column(type="integer", name="Id") |
||
32 | * |
||
33 | * @var int |
||
34 | */ |
||
35 | protected $id; |
||
36 | |||
37 | /** |
||
38 | * @ORM\ManyToOne(targetEntity="Newscoop\Entity\User") |
||
39 | * @ORM\JoinColumn(name="IdUser", referencedColumnName="Id") |
||
40 | * |
||
41 | * @var Newscoop\Entity\User |
||
42 | */ |
||
43 | protected $user; |
||
44 | |||
45 | /** |
||
46 | * @ORM\ManyToOne(targetEntity="Newscoop\PaywallBundle\Entity\Subscription") |
||
47 | * @ORM\JoinColumn(name="IdSubscription", referencedColumnName="id") |
||
48 | * |
||
49 | * @var Newscoop\PaywallBundle\Entity\Subscriptions |
||
50 | */ |
||
51 | protected $subscription; |
||
52 | |||
53 | /** |
||
54 | * @ORM\ManyToOne(targetEntity="Order", inversedBy="items") |
||
55 | * @ORM\JoinColumn(name="order_id", referencedColumnName="id", nullable=false) |
||
56 | * |
||
57 | * @var Order |
||
58 | */ |
||
59 | protected $order; |
||
60 | |||
61 | /** |
||
62 | * @ORM\Column(type="integer", name="discount_total") |
||
63 | * |
||
64 | * @var int |
||
65 | */ |
||
66 | protected $discountTotal = 0; |
||
67 | |||
68 | /** |
||
69 | * @ORM\ManyToOne(targetEntity="Newscoop\Entity\Publication") |
||
70 | * @ORM\JoinColumn(name="IdPublication", referencedColumnName="Id") |
||
71 | * |
||
72 | * @var Newscoop\Entity\Publication |
||
73 | */ |
||
74 | protected $publication; |
||
75 | |||
76 | /** |
||
77 | * @ORM\Column(type="decimal", name="ToPay") |
||
78 | * |
||
79 | * @var float |
||
80 | */ |
||
81 | protected $toPay = 0.0; |
||
82 | |||
83 | /** |
||
84 | * @ORM\Column(name="Type") |
||
85 | * |
||
86 | * @var string |
||
87 | */ |
||
88 | protected $type; |
||
89 | |||
90 | /** |
||
91 | * @ORM\Column(name="Currency") |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | protected $currency; |
||
96 | |||
97 | /** |
||
98 | * @ORM\ManyToOne(targetEntity="Newscoop\PaywallBundle\Entity\Trial") |
||
99 | * @ORM\JoinColumn(name="trial_id", referencedColumnName="id") |
||
100 | * |
||
101 | * @var Newscoop\PaywallBundle\Entity\Trial |
||
102 | */ |
||
103 | protected $trial; |
||
104 | |||
105 | /** |
||
106 | * Subscription status visible for admin. |
||
107 | * |
||
108 | * @ORM\Column(name="Active") |
||
109 | * |
||
110 | * @var string |
||
111 | */ |
||
112 | protected $active; |
||
113 | |||
114 | /** |
||
115 | * @ORM\Column(type="datetime", name="created_at") |
||
116 | * |
||
117 | * @var DateTime |
||
118 | */ |
||
119 | protected $created_at; |
||
120 | |||
121 | /** |
||
122 | * @ORM\Column(type="datetime", name="expire_at", nullable=true) |
||
123 | * |
||
124 | * @var DateTime |
||
125 | */ |
||
126 | protected $expire_at; |
||
127 | |||
128 | /** |
||
129 | * Custom field. |
||
130 | * |
||
131 | * @ORM\Column(type="boolean", name="custom") |
||
132 | * |
||
133 | * @var bool |
||
134 | */ |
||
135 | protected $custom; |
||
136 | |||
137 | /** |
||
138 | * Second custom field. |
||
139 | * |
||
140 | * @ORM\Column(type="boolean", name="custom_2") |
||
141 | * |
||
142 | * @var bool |
||
143 | */ |
||
144 | protected $customOther; |
||
145 | |||
146 | /** |
||
147 | * To hide from users totally. |
||
148 | * |
||
149 | * @ORM\Column(type="boolean", name="is_active") |
||
150 | * |
||
151 | * @var bool |
||
152 | */ |
||
153 | protected $is_active; |
||
154 | |||
155 | /** |
||
156 | * Is prolonged? |
||
157 | * |
||
158 | * @ORM\Column(type="boolean", name="prolonged") |
||
159 | * |
||
160 | * @var bool |
||
161 | */ |
||
162 | protected $prolonged = false; |
||
163 | |||
164 | /** |
||
165 | * @ORM\Column(type="datetime", name="notify_sent_first", nullable=true) |
||
166 | * |
||
167 | * @var \DateTime |
||
168 | */ |
||
169 | protected $notifySentLevelOne; |
||
170 | |||
171 | /** |
||
172 | * @ORM\Column(type="datetime", name="notify_sent_second", nullable=true) |
||
173 | * |
||
174 | * @var \DateTime |
||
175 | */ |
||
176 | protected $notifySentLevelTwo; |
||
177 | |||
178 | /** |
||
179 | * @ORM\Column(type="datetime", name="updated_at", nullable=true) |
||
180 | * |
||
181 | * @var \DateTime |
||
182 | */ |
||
183 | protected $updated; |
||
184 | |||
185 | /** |
||
186 | * @ORM\Column(type="array", name="duration") |
||
187 | * |
||
188 | * @var array |
||
189 | */ |
||
190 | protected $duration; |
||
191 | |||
192 | protected $discount; |
||
193 | |||
194 | /** |
||
195 | * @ORM\OneToMany(targetEntity="Modification", mappedBy="orderItem", orphanRemoval=true, cascade={"all"}) |
||
196 | * |
||
197 | * @var ArrayCollection |
||
198 | */ |
||
199 | protected $modifications; |
||
200 | |||
201 | /** |
||
202 | * @ORM\ManyToMany(targetEntity="Discount", cascade={"persist"}) |
||
203 | * @ORM\JoinTable(name="plugin_paywall_order_item_discount", |
||
204 | * joinColumns={ |
||
205 | * @ORM\JoinColumn(name="order_item_id", referencedColumnName="Id") |
||
206 | * }, |
||
207 | * inverseJoinColumns={ |
||
208 | * @ORM\JoinColumn(name="discount_id", referencedColumnName="id") |
||
209 | * } |
||
210 | * ) |
||
211 | * |
||
212 | * @var Discount |
||
213 | */ |
||
214 | protected $discounts; |
||
215 | |||
216 | /** |
||
217 | * @ORM\ManyToOne(targetEntity="UserSubscription", inversedBy="children") |
||
218 | * @ORM\JoinColumn(name="parent_id", referencedColumnName="Id", onDelete="SET NULL") |
||
219 | * |
||
220 | * @var UserSubscription |
||
221 | */ |
||
222 | protected $parent; |
||
223 | |||
224 | /** |
||
225 | * @ORM\OneToMany(targetEntity="UserSubscription", mappedBy="parent") |
||
226 | * @ORM\OrderBy({"created_at" = "DESC"}) |
||
227 | */ |
||
228 | protected $children; |
||
229 | |||
230 | /** |
||
231 | * @ORM\Column(type="datetime", name="starts_at", nullable=true) |
||
232 | * |
||
233 | * @var DateTime |
||
234 | */ |
||
235 | protected $startsAt; |
||
236 | |||
237 | public function __construct() |
||
238 | { |
||
239 | $this->currency = ''; |
||
240 | $this->active = 'N'; |
||
241 | $this->created_at = new \DateTime(); |
||
0 ignored issues
–
show
|
|||
242 | $this->is_active = false; |
||
243 | $this->custom = false; |
||
244 | $this->customOther = false; |
||
245 | $this->type = self::TYPE_PAID; |
||
246 | $this->notifySentLevelOne = null; |
||
247 | $this->notifySentLevelTwo = null; |
||
248 | $this->modifications = new ArrayCollection(); |
||
249 | $this->discounts = new ArrayCollection(); |
||
0 ignored issues
–
show
It seems like
new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<Newscoop\PaywallBundle\Entity\Discount> of property $discounts .
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.. ![]() |
|||
250 | } |
||
251 | |||
252 | /** |
||
253 | * Get id. |
||
254 | * |
||
255 | * @return int |
||
256 | */ |
||
257 | public function getId() |
||
258 | { |
||
259 | return (int) $this->id; |
||
260 | } |
||
261 | |||
262 | /** |
||
263 | * Set subscription. |
||
264 | * |
||
265 | * @param Newscoop\PaywallBundle\Entity\Subscription $subscription |
||
266 | */ |
||
267 | public function setSubscription($subscription) |
||
268 | { |
||
269 | $this->subscription = $subscription; |
||
0 ignored issues
–
show
It seems like
$subscription of type object<Newscoop\PaywallB...le\Entity\Subscription> is incompatible with the declared type object<Newscoop\PaywallB...e\Entity\Subscriptions> of property $subscription .
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.. ![]() |
|||
270 | |||
271 | return $this; |
||
272 | } |
||
273 | |||
274 | /** |
||
275 | * Get subscription. |
||
276 | * |
||
277 | * @return Newscoop\PaywallBundle\Entity\Subscription_specification |
||
278 | */ |
||
279 | public function getSubscription() |
||
280 | { |
||
281 | return $this->subscription; |
||
282 | } |
||
283 | |||
284 | /** |
||
285 | * Set user. |
||
286 | * |
||
287 | * @param Newscoop\Entity\User $user |
||
288 | */ |
||
289 | public function setUser(User $user) |
||
290 | { |
||
291 | $this->user = $user; |
||
0 ignored issues
–
show
It seems like
$user of type object<Newscoop\Entity\User> is incompatible with the declared type object<Newscoop\PaywallB...y\Newscoop\Entity\User> of property $user .
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.. ![]() |
|||
292 | |||
293 | return $this; |
||
294 | } |
||
295 | |||
296 | /** |
||
297 | * Get user. |
||
298 | * |
||
299 | * @return Newscoop\Entity\User |
||
300 | */ |
||
301 | public function getUser() |
||
302 | { |
||
303 | return $this->user; |
||
304 | } |
||
305 | |||
306 | /** |
||
307 | * Set publication. |
||
308 | * |
||
309 | * @param Newscoop\Entity\Publication $publication |
||
310 | * |
||
311 | * @return Newscoop\Entity\Subscription |
||
312 | */ |
||
313 | public function setPublication(Publication $publication) |
||
314 | { |
||
315 | $this->publication = $publication; |
||
0 ignored issues
–
show
It seems like
$publication of type object<Newscoop\Entity\Publication> is incompatible with the declared type object<Newscoop\PaywallB...oop\Entity\Publication> of property $publication .
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.. ![]() |
|||
316 | |||
317 | return $this; |
||
318 | } |
||
319 | |||
320 | /** |
||
321 | * Get publication. |
||
322 | * |
||
323 | * @return Newscoop\Entity\Publication |
||
324 | */ |
||
325 | public function getPublication() |
||
326 | { |
||
327 | return $this->publication; |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * Get publication name. |
||
332 | * |
||
333 | * @return string |
||
334 | */ |
||
335 | public function getPublicationName() |
||
336 | { |
||
337 | return $this->publication->getName(); |
||
338 | } |
||
339 | |||
340 | /** |
||
341 | * Get publication id. |
||
342 | * |
||
343 | * @return int |
||
344 | */ |
||
345 | public function getPublicationId() |
||
346 | { |
||
347 | return $this->publication->getId(); |
||
348 | } |
||
349 | |||
350 | /** |
||
351 | * Set to pay. |
||
352 | * |
||
353 | * @param float $toPay |
||
354 | * |
||
355 | * @return Newscoop\Entity\Subscription |
||
356 | */ |
||
357 | public function setToPay($toPay) |
||
358 | { |
||
359 | $this->toPay = (float) $toPay; |
||
360 | |||
361 | return $this; |
||
362 | } |
||
363 | |||
364 | /** |
||
365 | * Get to pay. |
||
366 | * |
||
367 | * @return float |
||
368 | */ |
||
369 | public function getToPay() |
||
370 | { |
||
371 | return (float) $this->toPay; |
||
372 | } |
||
373 | |||
374 | /** |
||
375 | * Set to pay. |
||
376 | * |
||
377 | * @param float $toPay |
||
378 | * |
||
379 | * @return Newscoop\Entity\Subscription |
||
380 | */ |
||
381 | public function setPrice($toPay) |
||
382 | { |
||
383 | $this->toPay = (float) $toPay; |
||
384 | |||
385 | return $this; |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * Get to pay. |
||
390 | * |
||
391 | * @return float |
||
392 | */ |
||
393 | public function getPrice() |
||
394 | { |
||
395 | return (float) $this->toPay; |
||
396 | } |
||
397 | |||
398 | /** |
||
399 | * Set type. |
||
400 | * |
||
401 | * @param string $type |
||
402 | * |
||
403 | * @return Newscoop\Entity\Subscription |
||
404 | */ |
||
405 | public function setType($type) |
||
406 | { |
||
407 | $this->type = strtoupper($type) === self::TYPE_TRIAL ? self::TYPE_TRIAL : self::TYPE_PAID; |
||
408 | |||
409 | return $this; |
||
410 | } |
||
411 | |||
412 | /** |
||
413 | * Get type. |
||
414 | * |
||
415 | * @return string |
||
416 | */ |
||
417 | public function getType() |
||
418 | { |
||
419 | return $this->type; |
||
420 | } |
||
421 | |||
422 | /** |
||
423 | * Test if is trial. |
||
424 | * |
||
425 | * @return bool |
||
426 | */ |
||
427 | public function isTrial() |
||
428 | { |
||
429 | return $this->type === self::TYPE_TRIAL; |
||
430 | } |
||
431 | |||
432 | /** |
||
433 | * Set active. |
||
434 | * |
||
435 | * @param bool $active |
||
436 | * |
||
437 | * @return Newscoop\Entity\Subscription |
||
438 | */ |
||
439 | public function setActive($active) |
||
440 | { |
||
441 | $this->active = 'N'; |
||
442 | if ($active) { |
||
443 | $this->active = 'Y'; |
||
444 | } |
||
445 | |||
446 | return $this; |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * Is active. |
||
451 | * |
||
452 | * @return bool |
||
453 | */ |
||
454 | public function isActive() |
||
455 | { |
||
456 | return strtoupper($this->active) === 'Y'; |
||
457 | } |
||
458 | |||
459 | /** |
||
460 | * Get currency. |
||
461 | * |
||
462 | * @return string |
||
463 | */ |
||
464 | public function getCurrency() |
||
465 | { |
||
466 | return $this->currency; |
||
467 | } |
||
468 | |||
469 | /** |
||
470 | * Set currency. |
||
471 | * |
||
472 | * @return string |
||
473 | */ |
||
474 | public function setCurrency($currency) |
||
475 | { |
||
476 | $this->currency = $currency; |
||
477 | |||
478 | return $this; |
||
479 | } |
||
480 | |||
481 | /** |
||
482 | * Get trial. |
||
483 | * |
||
484 | * @return Trial |
||
485 | */ |
||
486 | public function getTrial() |
||
487 | { |
||
488 | return $this->trial; |
||
489 | } |
||
490 | |||
491 | /** |
||
492 | * Set trial. |
||
493 | * |
||
494 | * @return Trial |
||
495 | */ |
||
496 | public function setTrial($trial) |
||
497 | { |
||
498 | $this->trial = $trial; |
||
499 | |||
500 | return $this; |
||
501 | } |
||
502 | |||
503 | /** |
||
504 | * Get create date. |
||
505 | * |
||
506 | * @return datetime |
||
507 | */ |
||
508 | public function getCreatedAt() |
||
509 | { |
||
510 | return $this->created_at; |
||
511 | } |
||
512 | |||
513 | /** |
||
514 | * Set create date. |
||
515 | * |
||
516 | * @param datetime $created_at |
||
517 | * |
||
518 | * @return datetime |
||
519 | */ |
||
520 | public function setCreatedAt(\DateTime $created_at) |
||
521 | { |
||
522 | $this->created_at = $created_at; |
||
0 ignored issues
–
show
It seems like
$created_at of type object<DateTime> is incompatible with the declared type object<Newscoop\PaywallBundle\Entity\datetime> of property $created_at .
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.. ![]() |
|||
523 | |||
524 | return $this; |
||
525 | } |
||
526 | |||
527 | /** |
||
528 | * Get expire date. |
||
529 | * |
||
530 | * @return datetime |
||
531 | */ |
||
532 | public function getExpireAt() |
||
533 | { |
||
534 | return $this->expire_at; |
||
535 | } |
||
536 | |||
537 | /** |
||
538 | * Set expire date. |
||
539 | * |
||
540 | * @param datetime $expire_at |
||
541 | * |
||
542 | * @return datetime |
||
543 | */ |
||
544 | public function setExpireAt(\DateTime $expire_at = null) |
||
545 | { |
||
546 | $this->expire_at = $expire_at; |
||
547 | |||
548 | return $this; |
||
549 | } |
||
550 | |||
551 | /** |
||
552 | * Get status. |
||
553 | * |
||
554 | * @return bool |
||
555 | */ |
||
556 | public function getIsActive() |
||
557 | { |
||
558 | return $this->is_active; |
||
559 | } |
||
560 | |||
561 | /** |
||
562 | * Set status. |
||
563 | * |
||
564 | * @param bool $is_active |
||
565 | * |
||
566 | * @return bool |
||
567 | */ |
||
568 | public function setIsActive($is_active) |
||
569 | { |
||
570 | $this->is_active = $is_active; |
||
571 | |||
572 | return $this; |
||
573 | } |
||
574 | |||
575 | /** |
||
576 | * Gets the Custom field. |
||
577 | * |
||
578 | * @return bool |
||
579 | */ |
||
580 | public function getCustom() |
||
581 | { |
||
582 | return $this->custom; |
||
583 | } |
||
584 | |||
585 | /** |
||
586 | * Sets the Custom field. |
||
587 | * |
||
588 | * @param bool $custom the custom |
||
589 | * |
||
590 | * @return self |
||
591 | */ |
||
592 | public function setCustom($custom) |
||
593 | { |
||
594 | $this->custom = $custom; |
||
595 | |||
596 | return $this; |
||
597 | } |
||
598 | |||
599 | /** |
||
600 | * Gets the Second custom field. |
||
601 | * |
||
602 | * @return bool |
||
603 | */ |
||
604 | public function getCustomOther() |
||
605 | { |
||
606 | return $this->customOther; |
||
607 | } |
||
608 | |||
609 | /** |
||
610 | * Sets the Second custom field. |
||
611 | * |
||
612 | * @param bool $customOther the custom other |
||
613 | * |
||
614 | * @return self |
||
615 | */ |
||
616 | public function setCustomOther($customOther) |
||
617 | { |
||
618 | $this->customOther = $customOther; |
||
619 | |||
620 | return $this; |
||
621 | } |
||
622 | |||
623 | /** |
||
624 | * Gets the value of updated. |
||
625 | * |
||
626 | * @return DateTime |
||
627 | */ |
||
628 | public function getUpdated() |
||
629 | { |
||
630 | return $this->updated; |
||
631 | } |
||
632 | |||
633 | /** |
||
634 | * Sets the value of updated. |
||
635 | * |
||
636 | * @param DateTime $updated the updated |
||
637 | * |
||
638 | * @return self |
||
639 | */ |
||
640 | public function setUpdated(\DateTime $updated) |
||
641 | { |
||
642 | $this->updated = $updated; |
||
643 | |||
644 | return $this; |
||
645 | } |
||
646 | |||
647 | /** |
||
648 | * Gets the value of notifySentLevelOne. |
||
649 | * |
||
650 | * @return \DateTime |
||
651 | */ |
||
652 | public function getNotifySentLevelOne() |
||
653 | { |
||
654 | return $this->notifySentLevelOne; |
||
655 | } |
||
656 | |||
657 | /** |
||
658 | * Sets the value of notifySentLevelOne. |
||
659 | * |
||
660 | * @param \DateTime $notifySentLevelOne the notify sent level one |
||
661 | * |
||
662 | * @return self |
||
663 | */ |
||
664 | public function setNotifySentLevelOne(\DateTime $notifySentLevelOne) |
||
665 | { |
||
666 | $this->notifySentLevelOne = $notifySentLevelOne; |
||
667 | |||
668 | return $this; |
||
669 | } |
||
670 | |||
671 | /** |
||
672 | * Gets the value of notifySentLevelTwo. |
||
673 | * |
||
674 | * @return \DateTime |
||
675 | */ |
||
676 | public function getNotifySentLevelTwo() |
||
677 | { |
||
678 | return $this->notifySentLevelTwo; |
||
679 | } |
||
680 | |||
681 | /** |
||
682 | * Sets the value of notifySentLevelTwo. |
||
683 | * |
||
684 | * @param \DateTime $notifySentLevelTwo the notify sent level two |
||
685 | * |
||
686 | * @return self |
||
687 | */ |
||
688 | public function setNotifySentLevelTwo(\DateTime $notifySentLevelTwo) |
||
689 | { |
||
690 | $this->notifySentLevelTwo = $notifySentLevelTwo; |
||
691 | |||
692 | return $this; |
||
693 | } |
||
694 | |||
695 | /** |
||
696 | * Gets the value of discount. |
||
697 | * |
||
698 | * @return array |
||
699 | */ |
||
700 | public function getDiscount() |
||
701 | { |
||
702 | return $this->discount; |
||
703 | } |
||
704 | |||
705 | /** |
||
706 | * Sets the value of discount. |
||
707 | * |
||
708 | * @param array $discount the discount |
||
709 | * |
||
710 | * @return self |
||
711 | */ |
||
712 | public function setDiscount($discount) |
||
713 | { |
||
714 | $this->discount = $discount; |
||
715 | |||
716 | return $this; |
||
717 | } |
||
718 | |||
719 | /** |
||
720 | * Gets the value of duration. |
||
721 | * |
||
722 | * @return array |
||
723 | */ |
||
724 | public function getDuration() |
||
725 | { |
||
726 | return $this->duration; |
||
727 | } |
||
728 | |||
729 | /** |
||
730 | * Sets the value of duration. |
||
731 | * |
||
732 | * @param array $duration the duration |
||
733 | * |
||
734 | * @return self |
||
735 | */ |
||
736 | public function setDuration($duration) |
||
737 | { |
||
738 | $this->duration = $duration; |
||
739 | |||
740 | return $this; |
||
741 | } |
||
742 | |||
743 | /** |
||
744 | * Gets the value of order. |
||
745 | * |
||
746 | * @return Order |
||
747 | */ |
||
748 | public function getOrder() |
||
749 | { |
||
750 | return $this->order; |
||
751 | } |
||
752 | |||
753 | /** |
||
754 | * Sets the value of order. |
||
755 | * |
||
756 | * @param Order $order the order |
||
757 | * |
||
758 | * @return self |
||
759 | */ |
||
760 | public function setOrder(Order $order) |
||
761 | { |
||
762 | $this->order = $order; |
||
763 | |||
764 | return $this; |
||
765 | } |
||
766 | |||
767 | /** |
||
768 | * {@inheritdoc} |
||
769 | */ |
||
770 | public function getDiscountTotal() |
||
771 | { |
||
772 | return $this->discountTotal / 100; |
||
773 | } |
||
774 | |||
775 | /** |
||
776 | * {@inheritdoc} |
||
777 | */ |
||
778 | public function setDiscountTotal($discountTotal) |
||
779 | { |
||
780 | $this->discountTotal = $discountTotal * 100; |
||
781 | |||
782 | return $this; |
||
783 | } |
||
784 | |||
785 | /** |
||
786 | * Gets the value of modifications. |
||
787 | * Can filter modifications by type. |
||
788 | * |
||
789 | * @return ArrayCollection |
||
790 | */ |
||
791 | public function getModifications($type = null) |
||
792 | { |
||
793 | if (null === $type) { |
||
794 | return $this->modifications; |
||
795 | } |
||
796 | |||
797 | return $this->modifications->filter(function (Modification $modification) use ($type) { |
||
798 | return $type === $modification->getLabel(); |
||
799 | }); |
||
800 | } |
||
801 | |||
802 | /** |
||
803 | * Sets the value of modifications. |
||
804 | * |
||
805 | * @param ArrayCollection $modifications the modifications |
||
806 | * |
||
807 | * @return self |
||
808 | */ |
||
809 | public function setModifications(ArrayCollection $modifications) |
||
810 | { |
||
811 | $this->modifications = $modifications; |
||
812 | |||
813 | return $this; |
||
814 | } |
||
815 | |||
816 | public function addModification(Modification $modification) |
||
817 | { |
||
818 | if (!$this->hasModification($modification)) { |
||
819 | $modification->setOrderItem($this); |
||
820 | $this->modifications->add($modification); |
||
821 | } |
||
822 | |||
823 | return $this; |
||
824 | } |
||
825 | |||
826 | public function hasModification(Modification $modification) |
||
827 | { |
||
828 | return $this->modifications->contains($modification); |
||
829 | } |
||
830 | |||
831 | public function removeModification(Modification $modification) |
||
832 | { |
||
833 | if ($this->hasModification($modification)) { |
||
834 | $modification->setOrderItem(null); |
||
835 | $this->modifications->removeElement($modification); |
||
836 | } |
||
837 | |||
838 | return $this; |
||
839 | } |
||
840 | |||
841 | public function addDiscount($discount) |
||
842 | { |
||
843 | if (!$this->hasDiscount($discount)) { |
||
844 | $this->discounts->add($discount); |
||
0 ignored issues
–
show
The method
add() does not seem to exist on object<Newscoop\PaywallBundle\Entity\Discount> .
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. ![]() |
|||
845 | } |
||
846 | |||
847 | return $this; |
||
848 | } |
||
849 | |||
850 | public function hasDiscount($discount) |
||
851 | { |
||
852 | return $this->discounts->contains($discount); |
||
0 ignored issues
–
show
The method
contains() does not seem to exist on object<Newscoop\PaywallBundle\Entity\Discount> .
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. ![]() |
|||
853 | } |
||
854 | |||
855 | public function removeDiscount($discount) |
||
856 | { |
||
857 | if ($this->hasDiscount($discount)) { |
||
858 | $this->discounts->removeElement($discount); |
||
0 ignored issues
–
show
The method
removeElement() does not seem to exist on object<Newscoop\PaywallBundle\Entity\Discount> .
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. ![]() |
|||
859 | } |
||
860 | |||
861 | return $this; |
||
862 | } |
||
863 | |||
864 | /** |
||
865 | * Gets the discounts. |
||
866 | * |
||
867 | * @return Discount |
||
868 | */ |
||
869 | public function getDiscounts() |
||
870 | { |
||
871 | return $this->discounts; |
||
872 | } |
||
873 | |||
874 | /** |
||
875 | * Sets the discounts. |
||
876 | * |
||
877 | * @param ArrayCollection $discounts the discounts |
||
878 | * |
||
879 | * @return self |
||
880 | */ |
||
881 | public function setDiscounts($discounts) |
||
882 | { |
||
883 | $this->discounts = $discounts; |
||
0 ignored issues
–
show
It seems like
$discounts of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<Newscoop\PaywallBundle\Entity\Discount> of property $discounts .
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.. ![]() |
|||
884 | |||
885 | return $this; |
||
886 | } |
||
887 | |||
888 | public function calculateToPay() |
||
889 | { |
||
890 | $this->calculateModificationsAndToPay(); |
||
891 | |||
892 | return $this; |
||
893 | } |
||
894 | |||
895 | /** |
||
896 | * Calculates all the modifications together with |
||
897 | * the total discount and unit price for single item. |
||
898 | * |
||
899 | * @return self |
||
900 | */ |
||
901 | public function calculateModificationsAndToPay() |
||
902 | { |
||
903 | $this->discountTotal = 0; |
||
904 | foreach ($this->modifications as $modification) { |
||
905 | $this->toPay -= $modification->getAmount(); |
||
906 | $this->discountTotal -= $modification->getAmount() * $this->duration['value'] * 100; |
||
907 | } |
||
908 | |||
909 | $this->toPay = (float) $this->toPay * $this->duration['value']; |
||
910 | if ($this->toPay < 0) { |
||
911 | $this->toPay = 0; |
||
912 | } |
||
913 | |||
914 | return $this; |
||
915 | } |
||
916 | |||
917 | /** |
||
918 | * {@inheritdoc} |
||
919 | */ |
||
920 | public function getProlonged() |
||
921 | { |
||
922 | return $this->prolonged; |
||
923 | } |
||
924 | |||
925 | /** |
||
926 | * {@inheritdoc} |
||
927 | */ |
||
928 | public function setProlonged($prolonged) |
||
929 | { |
||
930 | $this->prolonged = $prolonged; |
||
931 | |||
932 | return $this; |
||
933 | } |
||
934 | |||
935 | /** |
||
936 | * Gets the value of parent. |
||
937 | * |
||
938 | * @return UserSubscription |
||
939 | */ |
||
940 | public function getParent() |
||
941 | { |
||
942 | return $this->parent; |
||
943 | } |
||
944 | |||
945 | /** |
||
946 | * Sets the value of parent. |
||
947 | * |
||
948 | * @param UserSubscription $parent the parent |
||
949 | * |
||
950 | * @return self |
||
951 | */ |
||
952 | public function setParent(UserSubscription $parent) |
||
953 | { |
||
954 | $this->parent = $parent; |
||
955 | |||
956 | return $this; |
||
957 | } |
||
958 | |||
959 | /** |
||
960 | * Gets the value of children. |
||
961 | * |
||
962 | * @return mixed |
||
963 | */ |
||
964 | public function getChildren() |
||
965 | { |
||
966 | return $this->children; |
||
967 | } |
||
968 | |||
969 | /** |
||
970 | * Sets the value of children. |
||
971 | * |
||
972 | * @param mixed $children the children |
||
973 | * |
||
974 | * @return self |
||
975 | */ |
||
976 | public function setChildren($children) |
||
977 | { |
||
978 | $this->children = $children; |
||
979 | |||
980 | return $this; |
||
981 | } |
||
982 | |||
983 | /** |
||
984 | * Gets the value of startsAt. |
||
985 | * |
||
986 | * @return DateTime |
||
987 | */ |
||
988 | public function getStartsAt() |
||
989 | { |
||
990 | return $this->startsAt; |
||
991 | } |
||
992 | |||
993 | /** |
||
994 | * Sets the value of startsAt. |
||
995 | * |
||
996 | * @param DateTime $startsAt the starts at |
||
997 | * |
||
998 | * @return self |
||
999 | */ |
||
1000 | public function setStartsAt(\DateTime $startsAt) |
||
1001 | { |
||
1002 | $this->startsAt = $startsAt; |
||
0 ignored issues
–
show
It seems like
$startsAt of type object<DateTime> is incompatible with the declared type object<Newscoop\PaywallBundle\Entity\datetime> of property $startsAt .
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.. ![]() |
|||
1003 | |||
1004 | return $this; |
||
1005 | } |
||
1006 | } |
||
1007 |
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..