Passed
Push — master ( c86f31...6475fd )
by Sam
10:34
created

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