Passed
Push — typo3-v13 ( ba73f3...83a476 )
by Torben
02:10
created

PriceOption::setDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Domain\Model;
13
14
use DateTime;
15
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\DomainObject\AbstractEntity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
class PriceOption extends AbstractEntity
18
{
19
    protected string $title = '';
20
    protected string $description = '';
21
    protected float $price = 0.0;
22
    protected ?DateTime $validUntil = null;
23
    protected ?Event $event = null;
24
25
    public function getTitle(): string
26
    {
27
        return $this->title;
28
    }
29
30
    public function setTitle(string $title): void
31
    {
32
        $this->title = $title;
33
    }
34
35
    public function getDescription(): string
36
    {
37
        return $this->description;
38
    }
39
40
    public function setDescription(string $description): void
41
    {
42
        $this->description = $description;
43
    }
44
45
    public function getPrice(): float
46
    {
47
        return $this->price;
48
    }
49
50
    public function setPrice(float $price): void
51
    {
52
        $this->price = $price;
53
    }
54
55
    public function getValidUntil(): ?DateTime
56
    {
57
        return $this->validUntil;
58
    }
59
60
    public function setValidUntil(?DateTime $validUntil): void
61
    {
62
        $this->validUntil = $validUntil;
63
    }
64
65
    public function getEvent(): ?Event
66
    {
67
        return $this->event;
68
    }
69
70
    public function setEvent(?Event $event): void
71
    {
72
        $this->event = $event;
73
    }
74
75
    /**
76
     * Returns, if the current price option is valid (valid until date not expired)
77
     */
78
    public function getIsValid(): bool
79
    {
80
        if (!$this->getValidUntil()) {
81
            return true;
82
        }
83
84
        $compareDate = new DateTime('today midnight');
85
        return $this->getValidUntil() >= $compareDate;
86
    }
87
}
88