Passed
Push — 1.0.x ( 8353d5...3a2c37 )
by Julien
21:28
created

UserAbstract::setEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * This file is part of the Zemit Framework.
4
 *
5
 * (c) Zemit Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE.txt
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Zemit\Models\Abstracts;
14
15
use Phalcon\Db\RawValue;
16
use Zemit\Filter\Validation;
17
use Zemit\Models\AbstractModel;
18
use Zemit\Models\File;
19
use Zemit\Models\Oauth2;
20
use Zemit\Models\Profile;
21
use Zemit\Models\Session;
22
use Zemit\Models\UserFeature;
23
use Zemit\Models\Feature;
24
use Zemit\Models\UserGroup;
25
use Zemit\Models\Group;
26
use Zemit\Models\UserRole;
27
use Zemit\Models\Role;
28
use Zemit\Models\UserType;
29
use Zemit\Models\Type;
30
use Zemit\Models\User;
31
use Zemit\Models\Abstracts\Interfaces\UserAbstractInterface;
32
33
/**
34
 * Class UserAbstract
35
 *
36
 * This class defines a User abstract model that extends the AbstractModel class and implements the UserAbstractInterface.
37
 * It provides properties and methods for managing User data.
38
 * 
39
 * @property File[] $filelist
40
 * @property File[] $FileList
41
 * @method File[] getFileList(?array $params = null)
42
 *
43
 * @property Oauth2[] $oauth2list
44
 * @property Oauth2[] $Oauth2List
45
 * @method Oauth2[] getOauth2List(?array $params = null)
46
 *
47
 * @property Profile[] $profilelist
48
 * @property Profile[] $ProfileList
49
 * @method Profile[] getProfileList(?array $params = null)
50
 *
51
 * @property Session[] $sessionlist
52
 * @property Session[] $SessionList
53
 * @method Session[] getSessionList(?array $params = null)
54
 *
55
 * @property UserFeature[] $userfeaturelist
56
 * @property UserFeature[] $UserFeatureList
57
 * @method UserFeature[] getUserFeatureList(?array $params = null)
58
 *
59
 * @property Feature[] $featurelist
60
 * @property Feature[] $FeatureList
61
 * @method Feature[] getFeatureList(?array $params = null)
62
 *
63
 * @property UserGroup[] $usergrouplist
64
 * @property UserGroup[] $UserGroupList
65
 * @method UserGroup[] getUserGroupList(?array $params = null)
66
 *
67
 * @property Group[] $grouplist
68
 * @property Group[] $GroupList
69
 * @method Group[] getGroupList(?array $params = null)
70
 *
71
 * @property UserRole[] $userrolelist
72
 * @property UserRole[] $UserRoleList
73
 * @method UserRole[] getUserRoleList(?array $params = null)
74
 *
75
 * @property Role[] $rolelist
76
 * @property Role[] $RoleList
77
 * @method Role[] getRoleList(?array $params = null)
78
 *
79
 * @property UserType[] $usertypelist
80
 * @property UserType[] $UserTypeList
81
 * @method UserType[] getUserTypeList(?array $params = null)
82
 *
83
 * @property Type[] $typelist
84
 * @property Type[] $TypeList
85
 * @method Type[] getTypeList(?array $params = null)
86
 *
87
 * @property User $createdbyentity
88
 * @property User $CreatedByEntity
89
 * @method User getCreatedByEntity(?array $params = null)
90
 *
91
 * @property User $createdasentity
92
 * @property User $CreatedAsEntity
93
 * @method User getCreatedAsEntity(?array $params = null)
94
 *
95
 * @property User $updatedbyentity
96
 * @property User $UpdatedByEntity
97
 * @method User getUpdatedByEntity(?array $params = null)
98
 *
99
 * @property User $updatedasentity
100
 * @property User $UpdatedAsEntity
101
 * @method User getUpdatedAsEntity(?array $params = null)
102
 *
103
 * @property User $deletedasentity
104
 * @property User $DeletedAsEntity
105
 * @method User getDeletedAsEntity(?array $params = null)
106
 *
107
 * @property User $deletedbyentity
108
 * @property User $DeletedByEntity
109
 * @method User getDeletedByEntity(?array $params = null)
110
 *
111
 * @property User $restoredbyentity
112
 * @property User $RestoredByEntity
113
 * @method User getRestoredByEntity(?array $params = null)
114
 *
115
 * @property User $restoredasentity
116
 * @property User $RestoredAsEntity
117
 * @method User getRestoredAsEntity(?array $params = null)
118
 */
119
abstract class UserAbstract extends AbstractModel implements UserAbstractInterface
120
{
121
    /**
122
     * Column: id
123
     * Attributes: First | Primary | NotNull | Numeric | Unsigned | AutoIncrement
124
     * @var mixed
125
     */
126
    public mixed $id = null;
127
        
128
    /**
129
     * Column: uuid
130
     * Attributes: NotNull | Size(36) | Type(5)
131
     * @var mixed
132
     */
133
    public mixed $uuid = null;
134
        
135
    /**
136
     * Column: email
137
     * Attributes: NotNull | Size(255) | Type(2)
138
     * @var mixed
139
     */
140
    public mixed $email = null;
141
        
142
    /**
143
     * Column: password
144
     * Attributes: Size(255) | Type(2)
145
     * @var mixed
146
     */
147
    public mixed $password = null;
148
        
149
    /**
150
     * Column: deleted
151
     * Attributes: NotNull | Numeric | Unsigned | Type(26)
152
     * @var mixed
153
     */
154
    public mixed $deleted = 0;
155
        
156
    /**
157
     * Column: created_at
158
     * Attributes: NotNull | Type(4)
159
     * @var mixed
160
     */
161
    public mixed $createdAt = null;
162
        
163
    /**
164
     * Column: created_by
165
     * Attributes: Numeric | Unsigned
166
     * @var mixed
167
     */
168
    public mixed $createdBy = null;
169
        
170
    /**
171
     * Column: created_as
172
     * Attributes: Numeric | Unsigned
173
     * @var mixed
174
     */
175
    public mixed $createdAs = null;
176
        
177
    /**
178
     * Column: updated_at
179
     * Attributes: Type(4)
180
     * @var mixed
181
     */
182
    public mixed $updatedAt = null;
183
        
184
    /**
185
     * Column: updated_by
186
     * Attributes: Numeric | Unsigned
187
     * @var mixed
188
     */
189
    public mixed $updatedBy = null;
190
        
191
    /**
192
     * Column: updated_as
193
     * Attributes: Numeric | Unsigned
194
     * @var mixed
195
     */
196
    public mixed $updatedAs = null;
197
        
198
    /**
199
     * Column: deleted_at
200
     * Attributes: Type(4)
201
     * @var mixed
202
     */
203
    public mixed $deletedAt = null;
204
        
205
    /**
206
     * Column: deleted_as
207
     * Attributes: Numeric | Unsigned
208
     * @var mixed
209
     */
210
    public mixed $deletedAs = null;
211
        
212
    /**
213
     * Column: deleted_by
214
     * Attributes: Numeric | Unsigned
215
     * @var mixed
216
     */
217
    public mixed $deletedBy = null;
218
        
219
    /**
220
     * Column: restored_at
221
     * Attributes: Type(4)
222
     * @var mixed
223
     */
224
    public mixed $restoredAt = null;
225
        
226
    /**
227
     * Column: restored_by
228
     * Attributes: Numeric | Unsigned
229
     * @var mixed
230
     */
231
    public mixed $restoredBy = null;
232
        
233
    /**
234
     * Column: restored_as
235
     * Attributes: Numeric | Unsigned
236
     * @var mixed
237
     */
238
    public mixed $restoredAs = null;
239
    
240
    /**
241
     * Returns the value of field id
242
     * Column: id
243
     * Attributes: First | Primary | NotNull | Numeric | Unsigned | AutoIncrement
244
     * @return mixed
245
     */
246 2
    public function getId(): mixed
247
    {
248 2
        return $this->id;
249
    }
250
    
251
    /**
252
     * Sets the value of field id
253
     * Column: id 
254
     * Attributes: First | Primary | NotNull | Numeric | Unsigned | AutoIncrement
255
     * @param mixed $id
256
     * @return void
257
     */
258
    public function setId(mixed $id): void
259
    {
260
        $this->id = $id;
261
    }
262
    
263
    /**
264
     * Returns the value of field uuid
265
     * Column: uuid
266
     * Attributes: NotNull | Size(36) | Type(5)
267
     * @return mixed
268
     */
269 2
    public function getUuid(): mixed
270
    {
271 2
        return $this->uuid;
272
    }
273
    
274
    /**
275
     * Sets the value of field uuid
276
     * Column: uuid 
277
     * Attributes: NotNull | Size(36) | Type(5)
278
     * @param mixed $uuid
279
     * @return void
280
     */
281
    public function setUuid(mixed $uuid): void
282
    {
283
        $this->uuid = $uuid;
284
    }
285
    
286
    /**
287
     * Returns the value of field email
288
     * Column: email
289
     * Attributes: NotNull | Size(255) | Type(2)
290
     * @return mixed
291
     */
292 2
    public function getEmail(): mixed
293
    {
294 2
        return $this->email;
295
    }
296
    
297
    /**
298
     * Sets the value of field email
299
     * Column: email 
300
     * Attributes: NotNull | Size(255) | Type(2)
301
     * @param mixed $email
302
     * @return void
303
     */
304 2
    public function setEmail(mixed $email): void
305
    {
306 2
        $this->email = $email;
307
    }
308
    
309
    /**
310
     * Returns the value of field password
311
     * Column: password
312
     * Attributes: Size(255) | Type(2)
313
     * @return mixed
314
     */
315 2
    public function getPassword(): mixed
316
    {
317 2
        return $this->password;
318
    }
319
    
320
    /**
321
     * Sets the value of field password
322
     * Column: password 
323
     * Attributes: Size(255) | Type(2)
324
     * @param mixed $password
325
     * @return void
326
     */
327
    public function setPassword(mixed $password): void
328
    {
329
        $this->password = $password;
330
    }
331
    
332
    /**
333
     * Returns the value of field deleted
334
     * Column: deleted
335
     * Attributes: NotNull | Numeric | Unsigned | Type(26)
336
     * @return mixed
337
     */
338 2
    public function getDeleted(): mixed
339
    {
340 2
        return $this->deleted;
341
    }
342
    
343
    /**
344
     * Sets the value of field deleted
345
     * Column: deleted 
346
     * Attributes: NotNull | Numeric | Unsigned | Type(26)
347
     * @param mixed $deleted
348
     * @return void
349
     */
350
    public function setDeleted(mixed $deleted): void
351
    {
352
        $this->deleted = $deleted;
353
    }
354
    
355
    /**
356
     * Returns the value of field createdAt
357
     * Column: created_at
358
     * Attributes: NotNull | Type(4)
359
     * @return mixed
360
     */
361 2
    public function getCreatedAt(): mixed
362
    {
363 2
        return $this->createdAt;
364
    }
365
    
366
    /**
367
     * Sets the value of field createdAt
368
     * Column: created_at 
369
     * Attributes: NotNull | Type(4)
370
     * @param mixed $createdAt
371
     * @return void
372
     */
373
    public function setCreatedAt(mixed $createdAt): void
374
    {
375
        $this->createdAt = $createdAt;
376
    }
377
    
378
    /**
379
     * Returns the value of field createdBy
380
     * Column: created_by
381
     * Attributes: Numeric | Unsigned
382
     * @return mixed
383
     */
384 2
    public function getCreatedBy(): mixed
385
    {
386 2
        return $this->createdBy;
387
    }
388
    
389
    /**
390
     * Sets the value of field createdBy
391
     * Column: created_by 
392
     * Attributes: Numeric | Unsigned
393
     * @param mixed $createdBy
394
     * @return void
395
     */
396
    public function setCreatedBy(mixed $createdBy): void
397
    {
398
        $this->createdBy = $createdBy;
399
    }
400
    
401
    /**
402
     * Returns the value of field createdAs
403
     * Column: created_as
404
     * Attributes: Numeric | Unsigned
405
     * @return mixed
406
     */
407 2
    public function getCreatedAs(): mixed
408
    {
409 2
        return $this->createdAs;
410
    }
411
    
412
    /**
413
     * Sets the value of field createdAs
414
     * Column: created_as 
415
     * Attributes: Numeric | Unsigned
416
     * @param mixed $createdAs
417
     * @return void
418
     */
419
    public function setCreatedAs(mixed $createdAs): void
420
    {
421
        $this->createdAs = $createdAs;
422
    }
423
    
424
    /**
425
     * Returns the value of field updatedAt
426
     * Column: updated_at
427
     * Attributes: Type(4)
428
     * @return mixed
429
     */
430 2
    public function getUpdatedAt(): mixed
431
    {
432 2
        return $this->updatedAt;
433
    }
434
    
435
    /**
436
     * Sets the value of field updatedAt
437
     * Column: updated_at 
438
     * Attributes: Type(4)
439
     * @param mixed $updatedAt
440
     * @return void
441
     */
442
    public function setUpdatedAt(mixed $updatedAt): void
443
    {
444
        $this->updatedAt = $updatedAt;
445
    }
446
    
447
    /**
448
     * Returns the value of field updatedBy
449
     * Column: updated_by
450
     * Attributes: Numeric | Unsigned
451
     * @return mixed
452
     */
453 2
    public function getUpdatedBy(): mixed
454
    {
455 2
        return $this->updatedBy;
456
    }
457
    
458
    /**
459
     * Sets the value of field updatedBy
460
     * Column: updated_by 
461
     * Attributes: Numeric | Unsigned
462
     * @param mixed $updatedBy
463
     * @return void
464
     */
465
    public function setUpdatedBy(mixed $updatedBy): void
466
    {
467
        $this->updatedBy = $updatedBy;
468
    }
469
    
470
    /**
471
     * Returns the value of field updatedAs
472
     * Column: updated_as
473
     * Attributes: Numeric | Unsigned
474
     * @return mixed
475
     */
476 2
    public function getUpdatedAs(): mixed
477
    {
478 2
        return $this->updatedAs;
479
    }
480
    
481
    /**
482
     * Sets the value of field updatedAs
483
     * Column: updated_as 
484
     * Attributes: Numeric | Unsigned
485
     * @param mixed $updatedAs
486
     * @return void
487
     */
488
    public function setUpdatedAs(mixed $updatedAs): void
489
    {
490
        $this->updatedAs = $updatedAs;
491
    }
492
    
493
    /**
494
     * Returns the value of field deletedAt
495
     * Column: deleted_at
496
     * Attributes: Type(4)
497
     * @return mixed
498
     */
499 2
    public function getDeletedAt(): mixed
500
    {
501 2
        return $this->deletedAt;
502
    }
503
    
504
    /**
505
     * Sets the value of field deletedAt
506
     * Column: deleted_at 
507
     * Attributes: Type(4)
508
     * @param mixed $deletedAt
509
     * @return void
510
     */
511
    public function setDeletedAt(mixed $deletedAt): void
512
    {
513
        $this->deletedAt = $deletedAt;
514
    }
515
    
516
    /**
517
     * Returns the value of field deletedAs
518
     * Column: deleted_as
519
     * Attributes: Numeric | Unsigned
520
     * @return mixed
521
     */
522 2
    public function getDeletedAs(): mixed
523
    {
524 2
        return $this->deletedAs;
525
    }
526
    
527
    /**
528
     * Sets the value of field deletedAs
529
     * Column: deleted_as 
530
     * Attributes: Numeric | Unsigned
531
     * @param mixed $deletedAs
532
     * @return void
533
     */
534
    public function setDeletedAs(mixed $deletedAs): void
535
    {
536
        $this->deletedAs = $deletedAs;
537
    }
538
    
539
    /**
540
     * Returns the value of field deletedBy
541
     * Column: deleted_by
542
     * Attributes: Numeric | Unsigned
543
     * @return mixed
544
     */
545 2
    public function getDeletedBy(): mixed
546
    {
547 2
        return $this->deletedBy;
548
    }
549
    
550
    /**
551
     * Sets the value of field deletedBy
552
     * Column: deleted_by 
553
     * Attributes: Numeric | Unsigned
554
     * @param mixed $deletedBy
555
     * @return void
556
     */
557
    public function setDeletedBy(mixed $deletedBy): void
558
    {
559
        $this->deletedBy = $deletedBy;
560
    }
561
    
562
    /**
563
     * Returns the value of field restoredAt
564
     * Column: restored_at
565
     * Attributes: Type(4)
566
     * @return mixed
567
     */
568 2
    public function getRestoredAt(): mixed
569
    {
570 2
        return $this->restoredAt;
571
    }
572
    
573
    /**
574
     * Sets the value of field restoredAt
575
     * Column: restored_at 
576
     * Attributes: Type(4)
577
     * @param mixed $restoredAt
578
     * @return void
579
     */
580
    public function setRestoredAt(mixed $restoredAt): void
581
    {
582
        $this->restoredAt = $restoredAt;
583
    }
584
    
585
    /**
586
     * Returns the value of field restoredBy
587
     * Column: restored_by
588
     * Attributes: Numeric | Unsigned
589
     * @return mixed
590
     */
591 2
    public function getRestoredBy(): mixed
592
    {
593 2
        return $this->restoredBy;
594
    }
595
    
596
    /**
597
     * Sets the value of field restoredBy
598
     * Column: restored_by 
599
     * Attributes: Numeric | Unsigned
600
     * @param mixed $restoredBy
601
     * @return void
602
     */
603
    public function setRestoredBy(mixed $restoredBy): void
604
    {
605
        $this->restoredBy = $restoredBy;
606
    }
607
    
608
    /**
609
     * Returns the value of field restoredAs
610
     * Column: restored_as
611
     * Attributes: Numeric | Unsigned
612
     * @return mixed
613
     */
614 2
    public function getRestoredAs(): mixed
615
    {
616 2
        return $this->restoredAs;
617
    }
618
    
619
    /**
620
     * Sets the value of field restoredAs
621
     * Column: restored_as 
622
     * Attributes: Numeric | Unsigned
623
     * @param mixed $restoredAs
624
     * @return void
625
     */
626
    public function setRestoredAs(mixed $restoredAs): void
627
    {
628
        $this->restoredAs = $restoredAs;
629
    }
630
631
    /**
632
     * Adds the default relationships to the model.
633
     * @return void
634
     */
635 2
    public function addDefaultRelationships(): void
636
    {
637 2
        $this->hasMany('id', File::class, 'userId', ['alias' => 'FileList']);
638
639 2
        $this->hasMany('id', Oauth2::class, 'userId', ['alias' => 'Oauth2List']);
640
641 2
        $this->hasMany('id', Profile::class, 'userId', ['alias' => 'ProfileList']);
642
643 2
        $this->hasMany('id', Session::class, 'userId', ['alias' => 'SessionList']);
644
645 2
        $this->hasMany('id', UserFeature::class, 'userId', ['alias' => 'UserFeatureList']);
646
647 2
        $this->hasManyToMany(
648 2
            'id',
649 2
            UserFeature::class,
650 2
            'userId',
651 2
            'featureId',
652 2
            Feature::class,
653 2
            'id',
654 2
            ['alias' => 'FeatureList']
655 2
        );
656
657 2
        $this->hasMany('id', UserGroup::class, 'userId', ['alias' => 'UserGroupList']);
658
659 2
        $this->hasManyToMany(
660 2
            'id',
661 2
            UserGroup::class,
662 2
            'userId',
663 2
            'groupId',
664 2
            Group::class,
665 2
            'id',
666 2
            ['alias' => 'GroupList']
667 2
        );
668
669 2
        $this->hasMany('id', UserRole::class, 'userId', ['alias' => 'UserRoleList']);
670
671 2
        $this->hasManyToMany(
672 2
            'id',
673 2
            UserRole::class,
674 2
            'userId',
675 2
            'roleId',
676 2
            Role::class,
677 2
            'id',
678 2
            ['alias' => 'RoleList']
679 2
        );
680
681 2
        $this->hasMany('id', UserType::class, 'userId', ['alias' => 'UserTypeList']);
682
683 2
        $this->hasManyToMany(
684 2
            'id',
685 2
            UserType::class,
686 2
            'userId',
687 2
            'typeId',
688 2
            Type::class,
689 2
            'id',
690 2
            ['alias' => 'TypeList']
691 2
        );
692
693 2
        $this->belongsTo('createdBy', User::class, 'id', ['alias' => 'CreatedByEntity']);
694
695 2
        $this->belongsTo('createdAs', User::class, 'id', ['alias' => 'CreatedAsEntity']);
696
697 2
        $this->belongsTo('updatedBy', User::class, 'id', ['alias' => 'UpdatedByEntity']);
698
699 2
        $this->belongsTo('updatedAs', User::class, 'id', ['alias' => 'UpdatedAsEntity']);
700
701 2
        $this->belongsTo('deletedAs', User::class, 'id', ['alias' => 'DeletedAsEntity']);
702
703 2
        $this->belongsTo('deletedBy', User::class, 'id', ['alias' => 'DeletedByEntity']);
704
705 2
        $this->belongsTo('restoredBy', User::class, 'id', ['alias' => 'RestoredByEntity']);
706
707 2
        $this->belongsTo('restoredAs', User::class, 'id', ['alias' => 'RestoredAsEntity']);
708
    }
709
    
710
    /**
711
     * Adds the default validations to the model.
712
     * @param Validation|null $validator
713
     * @return Validation
714
     */
715 2
    public function addDefaultValidations(?Validation $validator = null): Validation
716
    {
717 2
        $validator ??= new Validation();
718
    
719 2
        $this->addUnsignedIntValidation($validator, 'id', true);
720 2
        $this->addStringLengthValidation($validator, 'uuid', 0, 36, false);
721 2
        $this->addStringLengthValidation($validator, 'email', 0, 255, false);
722 2
        $this->addStringLengthValidation($validator, 'password', 0, 255, true);
723 2
        $this->addUnsignedIntValidation($validator, 'deleted', false);
724 2
        $this->addDateTimeValidation($validator, 'createdAt', false);
725 2
        $this->addUnsignedIntValidation($validator, 'createdBy', true);
726 2
        $this->addUnsignedIntValidation($validator, 'createdAs', true);
727 2
        $this->addDateTimeValidation($validator, 'updatedAt', true);
728 2
        $this->addUnsignedIntValidation($validator, 'updatedBy', true);
729 2
        $this->addUnsignedIntValidation($validator, 'updatedAs', true);
730 2
        $this->addDateTimeValidation($validator, 'deletedAt', true);
731 2
        $this->addUnsignedIntValidation($validator, 'deletedAs', true);
732 2
        $this->addUnsignedIntValidation($validator, 'deletedBy', true);
733 2
        $this->addDateTimeValidation($validator, 'restoredAt', true);
734 2
        $this->addUnsignedIntValidation($validator, 'restoredBy', true);
735 2
        $this->addUnsignedIntValidation($validator, 'restoredAs', true);
736
        
737 2
        return $validator;
738
    }
739
740
        
741
    /**
742
     * Returns an array that maps the column names of the database
743
     * table to the corresponding property names of the model.
744
     * 
745
     * @returns array The array mapping the column names to the property names
746
     */
747 2
    public function columnMap(): array
748
    {
749 2
        return [
750 2
            'id' => 'id',
751 2
            'uuid' => 'uuid',
752 2
            'email' => 'email',
753 2
            'password' => 'password',
754 2
            'deleted' => 'deleted',
755 2
            'created_at' => 'createdAt',
756 2
            'created_by' => 'createdBy',
757 2
            'created_as' => 'createdAs',
758 2
            'updated_at' => 'updatedAt',
759 2
            'updated_by' => 'updatedBy',
760 2
            'updated_as' => 'updatedAs',
761 2
            'deleted_at' => 'deletedAt',
762 2
            'deleted_as' => 'deletedAs',
763 2
            'deleted_by' => 'deletedBy',
764 2
            'restored_at' => 'restoredAt',
765 2
            'restored_by' => 'restoredBy',
766 2
            'restored_as' => 'restoredAs',
767 2
        ];
768
    }
769
}
770