Failed Conditions
Push — master ( 1fa797...33b47a )
by Sam
10:08
created

Session::getEndDate()   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 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
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 $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
     * Used for filter + sorting. Represents the first date
79
     *
80
     * @var Date
81
     *
82
     * @ORM\Column(type="date")
83
     */
84
    private $endDate;
85
86
    /**
87
     * @var Collection
88
     * @ORM\ManyToMany(targetEntity="User", inversedBy="sessions")
89
     */
90
    private $facilitators;
91
92
    /**
93
     * Constructor
94
     */
95 3
    public function __construct()
96
    {
97 3
        $this->facilitators = new ArrayCollection();
98 3
    }
99
100
    public function getLocality(): string
101
    {
102
        return $this->locality;
103
    }
104
105
    public function setLocality(string $locality): void
106
    {
107
        $this->locality = $locality;
108
    }
109
110
    public function getRegion(): string
111
    {
112
        return $this->region;
113
    }
114
115
    public function setRegion(string $region): void
116
    {
117
        $this->region = $region;
118
    }
119
120
    public function getStreet(): string
121
    {
122
        return $this->street;
123
    }
124
125
    public function setStreet(string $street): void
126
    {
127
        $this->street = $street;
128
    }
129
130
    public function getPrice(): string
131
    {
132
        return $this->price;
133
    }
134
135
    public function setPrice(string $price): void
136
    {
137
        $this->price = $price;
138
    }
139
140
    public function getAvailability(): string
141
    {
142
        return $this->availability;
143
    }
144
145
    public function setAvailability(string $availability): void
146
    {
147
        $this->availability = $availability;
148
    }
149
150
    /**
151
     * List of dates
152
     *
153
     * @return string[]
154
     */
155
    public function getDates(): array
156
    {
157
        return $this->dates;
158
    }
159
160
    /**
161
     * List of dates
162
     *
163
     * @param string[] $dates
164
     */
165
    public function setDates(array $dates): void
166
    {
167
        $this->dates = $dates;
168
    }
169
170
    public function getStartDate(): Date
171
    {
172
        return $this->startDate;
173
    }
174
175
    public function setStartDate(Date $startDate): void
176
    {
177
        $this->startDate = $startDate;
178
    }
179
180
    public function getEndDate(): Date
181
    {
182
        return $this->endDate;
183
    }
184
185
    public function setEndDate(Date $endDate): void
186
    {
187
        $this->endDate = $endDate;
188
    }
189
190
    public function getFacilitators(): Collection
191
    {
192
        return $this->facilitators;
193
    }
194
195
    /**
196
     * Add facilitator
197
     */
198
    public function addFacilitator(User $facilitator): void
199
    {
200
        if (!$this->facilitators->contains($facilitator)) {
201
            $this->facilitators->add($facilitator);
202
            $facilitator->sessionAdded($this);
203
        }
204
    }
205
206
    /**
207
     * Remove facilitator
208
     */
209
    public function removeFacilitator(User $facilitator): void
210
    {
211
        $this->facilitators->removeElement($facilitator);
212
        $facilitator->sessionRemoved($this);
213
    }
214
}
215