Passed
Push — master ( 32e3d5...72f34a )
by Sam
11:26
created

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