Session::setEndDate()   A
last analyzed

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
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Model;
6
7
use Application\Repository\SessionRepository;
8
use Application\Traits\HasRichTextDescription;
9
use Cake\Chronos\ChronosDate;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\Common\Collections\Collection;
12
use Doctrine\ORM\Mapping as ORM;
13
use Ecodev\Felix\Model\Traits\HasInternalRemarks;
14
use Ecodev\Felix\Model\Traits\HasName;
15
16
/**
17
 * A session that a human can physically go to.
18
 */
19
#[ORM\Entity(SessionRepository::class)]
20
class Session extends AbstractModel
21
{
22
    use HasInternalRemarks;
23
    use HasName;
24
    use HasRichTextDescription;
25
26
    #[ORM\Column(type: 'string', options: ['default' => ''])]
27
    private string $region = '';
28
29
    #[ORM\Column(type: 'string', options: ['default' => ''])]
30
    private string $locality = '';
31
32
    #[ORM\Column(type: 'string', options: ['default' => ''])]
33
    private string $street = '';
34
35
    #[ORM\Column(type: 'string', options: ['default' => ''])]
36
    private string $mailingList = '';
37
38
    #[ORM\Column(type: 'string', options: ['default' => ''])]
39
    private string $price = '';
40
41
    #[ORM\Column(type: 'string', options: ['default' => ''])]
42
    private string $availability = '';
43
44
    /**
45
     * Used for display.
46
     *
47
     * @var string[]
48
     */
49
    #[ORM\Column(type: 'json')]
50
    private array $dates = [];
51
52
    /**
53
     * Used for filter + sorting. Represents the first date.
54
     */
55
    #[ORM\Column(type: 'date')]
56
    private ChronosDate $startDate;
57
58
    /**
59
     * Used for filter + sorting. Represents the first date.
60
     */
61
    #[ORM\Column(type: 'date')]
62
    private ChronosDate $endDate;
63
64
    /**
65
     * @var Collection<int, User>
66
     */
67
    #[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'sessions')]
68
    private Collection $facilitators;
69
70 3
    public function __construct()
71
    {
72 3
        $this->facilitators = new ArrayCollection();
73
    }
74
75
    public function getLocality(): string
76
    {
77
        return $this->locality;
78
    }
79
80
    public function setLocality(string $locality): void
81
    {
82
        $this->locality = $locality;
83
    }
84
85
    public function getRegion(): string
86
    {
87
        return $this->region;
88
    }
89
90
    public function setRegion(string $region): void
91
    {
92
        $this->region = $region;
93
    }
94
95
    public function getStreet(): string
96
    {
97
        return $this->street;
98
    }
99
100
    public function setStreet(string $street): void
101
    {
102
        $this->street = $street;
103
    }
104
105
    public function getMailingList(): string
106
    {
107
        return $this->mailingList;
108
    }
109
110
    public function setMailingList(string $mailingList): void
111
    {
112
        $this->mailingList = $mailingList;
113
    }
114
115
    public function getPrice(): string
116
    {
117
        return $this->price;
118
    }
119
120
    public function setPrice(string $price): void
121
    {
122
        $this->price = $price;
123
    }
124
125
    public function getAvailability(): string
126
    {
127
        return $this->availability;
128
    }
129
130
    public function setAvailability(string $availability): void
131
    {
132
        $this->availability = $availability;
133
    }
134
135
    /**
136
     * List of dates.
137
     *
138
     * @return string[]
139
     */
140
    public function getDates(): array
141
    {
142
        return $this->dates;
143
    }
144
145
    /**
146
     * List of dates.
147
     *
148
     * @param string[] $dates
149
     */
150
    public function setDates(array $dates): void
151
    {
152
        $this->dates = $dates;
153
    }
154
155
    public function getStartDate(): ChronosDate
156
    {
157
        return $this->startDate;
158
    }
159
160
    public function setStartDate(ChronosDate $startDate): void
161
    {
162
        $this->startDate = $startDate;
163
    }
164
165
    public function getEndDate(): ChronosDate
166
    {
167
        return $this->endDate;
168
    }
169
170
    public function setEndDate(ChronosDate $endDate): void
171
    {
172
        $this->endDate = $endDate;
173
    }
174
175
    public function getFacilitators(): Collection
176
    {
177
        return $this->facilitators;
178
    }
179
180
    /**
181
     * Add facilitator.
182
     */
183
    public function addFacilitator(User $facilitator): void
184
    {
185
        if (!$this->facilitators->contains($facilitator)) {
186
            $this->facilitators->add($facilitator);
187
            $facilitator->sessionAdded($this);
188
        }
189
    }
190
191
    /**
192
     * Remove facilitator.
193
     */
194
    public function removeFacilitator(User $facilitator): void
195
    {
196
        $this->facilitators->removeElement($facilitator);
197
        $facilitator->sessionRemoved($this);
198
    }
199
}
200