SlackIdentity   A
last analyzed

Complexity

Total Complexity 28

Size/Duplication

Total Lines 306
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 61.11%

Importance

Changes 0
Metric Value
wmc 28
lcom 0
cbo 2
dl 0
loc 306
ccs 44
cts 72
cp 0.6111
rs 10
c 0
b 0
f 0

28 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getSlackId() 0 4 1
A getEmail() 0 4 1
A getUser() 0 4 1
A getTeamId() 0 4 1
A setTeamId() 0 6 1
A getName() 0 4 1
A setName() 0 6 1
A isDeleted() 0 4 1
A setIsDeleted() 0 6 1
A getColor() 0 4 1
A setColor() 0 6 1
A getRealName() 0 4 1
A setRealName() 0 6 1
A getTz() 0 4 1
A setTz() 0 6 1
A getTzLabel() 0 4 1
A setTzLabel() 0 6 1
A getTzOffset() 0 4 1
A setTzOffset() 0 6 1
A isAdmin() 0 4 1
A setIsAdmin() 0 6 1
A isBot() 0 4 1
A setIsBot() 0 6 1
A getUpdated() 0 4 1
A setUpdated() 0 6 1
A isAppUser() 0 4 1
A setIsAppUser() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Entity\Access;
12
13
use App\Entity\EntityInterface;
14
use App\Entity\Traits;
15
use Doctrine\ORM\Mapping as ORM;
16
use PascalDeVink\ShortUuid\ShortUuid;
17
use Symfony\Bridge\Doctrine\Validator\Constraints as OrmAssert;
18
use Symfony\Component\Validator\Constraints as Assert;
19
20
/**
21
 * @ORM\Entity()
22
 * @ORM\Table(name="access_slack_identities")
23
 * @OrmAssert\UniqueEntity(fields={"slack_id"}, errorPath="slack_id", message="Slack ID already exist")
24
 * @OrmAssert\UniqueEntity(fields={"email"}, errorPath="email", message="Email already exist")
25
 * @OrmAssert\UniqueEntity(fields={"user"}, errorPath="user", message="User already exist")
26
 */
27
class SlackIdentity implements EntityInterface
28
{
29
    use Traits\PropertyIdGeneratedTrait;
30
31
    /**
32
     * @var string
33
     * @ORM\Column(name="slack_id", type="string", length=16, nullable=false)
34
     *
35
     * @Assert\NotBlank()
36
     * @Assert\Length(min="1", max="16")
37
     */
38
    private $slackId;
39
40
    /**
41
     * @var string
42
     * @ORM\Column(name="email", type="string", length=255, nullable=false, unique=true)
43
     *
44
     * @Assert\NotBlank()
45
     * @Assert\Email()
46
     * @Assert\Length(min="1", max="255")
47
     */
48
    private $email;
49
50
    /**
51
     * @var string
52
     * @ORM\Column(name="team_id", type="string", length=16, nullable=false)
53
     *
54
     * @Assert\NotBlank()
55
     * @Assert\Length(min="1", max="16")
56
     */
57
    private $teamId;
58
59
    /**
60
     * @var string
61
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
62
     *
63
     * @Assert\NotBlank()
64
     * @Assert\Length(min="1", max="255")
65
     */
66
    private $name;
67
68
    /**
69
     * @var bool
70
     * @ORM\Column(name="is_deleted", type="boolean", nullable=false)
71
     *
72
     * @Assert\NotBlank()
73
     */
74
    private $isDeleted;
75
76
    /**
77
     * @var string
78
     * @ORM\Column(name="color", type="string", length=6, nullable=false)
79
     *
80
     * @Assert\NotBlank()
81
     * @Assert\Length(min="1", max="6")
82
     */
83
    private $color;
84
85
    /**
86
     * @var string
87
     * @ORM\Column(name="real_name", type="string", length=255, nullable=false)
88
     *
89
     * @Assert\NotBlank()
90
     * @Assert\Length(min="1", max="255")
91
     */
92
    private $realName;
93
94
    /**
95
     * @var string
96
     * @ORM\Column(name="tz", type="string", length=63, nullable=false)
97
     *
98
     * @Assert\NotBlank()
99
     * @Assert\Length(min="1", max="63")
100
     */
101
    private $tz;
102
103
    /**
104
     * @var string
105
     * @ORM\Column(name="tz_label", type="string", length=63, nullable=false)
106
     *
107
     * @Assert\NotBlank()
108
     * @Assert\Length(min="1", max="63")
109
     */
110
    private $tzLabel;
111
112
    /**
113
     * @var int
114
     * @ORM\Column(name="tz_offset", type="integer", nullable=false)
115
     *
116
     * @Assert\NotBlank()
117
     */
118
    private $tzOffset;
119
120
    /**
121
     * @var bool
122
     * @ORM\Column(name="is_admin", type="boolean", nullable=false)
123
     *
124
     * @Assert\NotBlank()
125
     */
126
    private $isAdmin;
127
128
    /**
129
     * @var bool
130
     * @ORM\Column(name="is_bot", type="boolean", nullable=false)
131
     *
132
     * @Assert\NotBlank()
133
     */
134
    private $isBot;
135
136
    /**
137
     * @var int
138
     * @ORM\Column(name="updated", type="integer", nullable=false)
139
     *
140
     * @Assert\NotBlank()
141
     */
142
    private $updated;
143
144
    /**
145
     * @var bool
146
     * @ORM\Column(name="is_app_user", type="boolean", nullable=false)
147
     *
148
     * @Assert\NotBlank()
149
     */
150
    private $isAppUser;
151
152
    //-------------------------------------------------------------------------------------------
153
154
    /**
155
     * @var User
156
     * @ORM\OneToOne(targetEntity="App\Entity\Access\User", inversedBy="slackIdentity", cascade={"persist"})
157
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false, unique=true)
158
     * @Assert\NotBlank()
159
     */
160
    private $user;
161
162
    //-------------------------------------------------------------------------------------------
163
164 3
    public function __construct(User $user, string $slackId, string $email)
165
    {
166 3
        $this->id = ShortUuid::uuid4();
167 3
        $this->slackId = $slackId;
168 3
        $this->email = $email;
169 3
        $this->user = $user;
170 3
    }
171
172
    //-------------------------------------------------------------------------------------------
173
174 3
    public function getSlackId(): string
175
    {
176 3
        return $this->slackId;
177
    }
178
179
    public function getEmail(): string
180
    {
181
        return $this->email;
182
    }
183
184
    public function getUser(): User
185
    {
186
        return $this->user;
187
    }
188
189
    public function getTeamId(): string
190
    {
191
        return $this->teamId;
192
    }
193
194 3
    public function setTeamId(string $teamId): self
195
    {
196 3
        $this->teamId = $teamId;
197
198 3
        return $this;
199
    }
200
201
    public function getName(): string
202
    {
203
        return $this->name;
204
    }
205
206 3
    public function setName(string $name): self
207
    {
208 3
        $this->name = $name;
209
210 3
        return $this;
211
    }
212
213
    public function isDeleted(): bool
214
    {
215
        return $this->isDeleted;
216
    }
217
218 3
    public function setIsDeleted(bool $isDeleted): self
219
    {
220 3
        $this->isDeleted = $isDeleted;
221
222 3
        return $this;
223
    }
224
225
    public function getColor(): string
226
    {
227
        return $this->color;
228
    }
229
230 3
    public function setColor(string $color): self
231
    {
232 3
        $this->color = $color;
233
234 3
        return $this;
235
    }
236
237
    public function getRealName(): string
238
    {
239
        return $this->realName;
240
    }
241
242 3
    public function setRealName(string $realName): self
243
    {
244 3
        $this->realName = $realName;
245
246 3
        return $this;
247
    }
248
249
    public function getTz(): string
250
    {
251
        return $this->tz;
252
    }
253
254 3
    public function setTz(string $tz): self
255
    {
256 3
        $this->tz = $tz;
257
258 3
        return $this;
259
    }
260
261
    public function getTzLabel(): string
262
    {
263
        return $this->tzLabel;
264
    }
265
266 3
    public function setTzLabel(string $tzLabel): self
267
    {
268 3
        $this->tzLabel = $tzLabel;
269
270 3
        return $this;
271
    }
272
273
    public function getTzOffset(): int
274
    {
275
        return $this->tzOffset;
276
    }
277
278 3
    public function setTzOffset(int $tzOffset): self
279
    {
280 3
        $this->tzOffset = $tzOffset;
281
282 3
        return $this;
283
    }
284
285
    public function isAdmin(): bool
286
    {
287
        return $this->isAdmin;
288
    }
289
290 3
    public function setIsAdmin(bool $isAdmin): self
291
    {
292 3
        $this->isAdmin = $isAdmin;
293
294 3
        return $this;
295
    }
296
297
    public function isBot(): bool
298
    {
299
        return $this->isBot;
300
    }
301
302 3
    public function setIsBot(bool $isBot): self
303
    {
304 3
        $this->isBot = $isBot;
305
306 3
        return $this;
307
    }
308
309
    public function getUpdated(): int
310
    {
311
        return $this->updated;
312
    }
313
314 3
    public function setUpdated(int $updated): self
315
    {
316 3
        $this->updated = $updated;
317
318 3
        return $this;
319
    }
320
321
    public function isAppUser(): bool
322
    {
323
        return $this->isAppUser;
324
    }
325
326 3
    public function setIsAppUser(bool $isAppUser): self
327
    {
328 3
        $this->isAppUser = $isAppUser;
329
330 3
        return $this;
331
    }
332
}
333