Passed
Push — master ( eff4fb...57c190 )
by Sam
07:38
created

Session   A

Complexity

Total Complexity 23

Size/Duplication

Total Lines 193
Duplicated Lines 0 %

Test Coverage

Coverage 4.26%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 23
eloc 39
dl 0
loc 193
ccs 2
cts 47
cp 0.0426
rs 10
c 3
b 0
f 1

22 Methods

Rating   Name   Duplication   Size   Complexity  
A getFacilitators() 0 3 1
A removeFacilitator() 0 4 1
A getEndDate() 0 3 1
A setEndDate() 0 3 1
A addFacilitator() 0 5 2
A setAvailability() 0 3 1
A setMailingList() 0 3 1
A getRegion() 0 3 1
A setStartDate() 0 3 1
A getMailingList() 0 3 1
A getAvailability() 0 3 1
A setPrice() 0 3 1
A setDates() 0 3 1
A setLocality() 0 3 1
A getDates() 0 3 1
A getPrice() 0 3 1
A __construct() 0 3 1
A getStartDate() 0 3 1
A getLocality() 0 3 1
A setStreet() 0 3 1
A setRegion() 0 3 1
A getStreet() 0 3 1
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\HasInternalRemarks;
13
use Ecodev\Felix\Model\Traits\HasName;
14
15
/**
16
 * A session that a human can physically go to.
17
 *
18
 * @ORM\Entity(repositoryClass="Application\Repository\SessionRepository")
19
 */
20
class Session extends AbstractModel
21
{
22
    use HasInternalRemarks;
23
    use HasName;
24
    use HasRichTextDescription;
25
26
    /**
27
     * @ORM\Column(type="string", options={"default" = ""})
28
     */
29
    private string $region = '';
30
31
    /**
32
     * @ORM\Column(type="string", options={"default" = ""})
33
     */
34
    private string $locality = '';
35
36
    /**
37
     * @ORM\Column(type="string", options={"default" = ""})
38
     */
39
    private string $street = '';
40
41
    /**
42
     * @ORM\Column(type="string", options={"default" = ""})
43
     */
44
    private string $mailingList = '';
45
46
    /**
47
     * @ORM\Column(type="string", options={"default" = ""})
48
     */
49
    private string $price = '';
50
51
    /**
52
     * @ORM\Column(type="string", options={"default" = ""})
53
     */
54
    private string $availability = '';
55
56
    /**
57
     * Used for display.
58
     *
59
     * @var string[]
60
     *
61
     * @ORM\Column(type="json")
62
     */
63
    private array $dates = [];
64
65
    /**
66
     * Used for filter + sorting. Represents the first date.
67
     *
68
     * @ORM\Column(type="date")
69
     */
70
    private Date $startDate;
71
72
    /**
73
     * Used for filter + sorting. Represents the first date.
74
     *
75
     * @ORM\Column(type="date")
76
     */
77
    private Date $endDate;
78
79
    /**
80
     * @var Collection<User>
81
     * @ORM\ManyToMany(targetEntity="User", inversedBy="sessions")
82
     */
83
    private Collection $facilitators;
84
85 3
    public function __construct()
86
    {
87 3
        $this->facilitators = new ArrayCollection();
88
    }
89
90
    public function getLocality(): string
91
    {
92
        return $this->locality;
93
    }
94
95
    public function setLocality(string $locality): void
96
    {
97
        $this->locality = $locality;
98
    }
99
100
    public function getRegion(): string
101
    {
102
        return $this->region;
103
    }
104
105
    public function setRegion(string $region): void
106
    {
107
        $this->region = $region;
108
    }
109
110
    public function getStreet(): string
111
    {
112
        return $this->street;
113
    }
114
115
    public function setStreet(string $street): void
116
    {
117
        $this->street = $street;
118
    }
119
120
    public function getMailingList(): string
121
    {
122
        return $this->mailingList;
123
    }
124
125
    public function setMailingList(string $mailingList): void
126
    {
127
        $this->mailingList = $mailingList;
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