Completed
Push — master ( 5909bf...4f0a67 )
by Andrii
06:13
created

Identity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 2
cbo 0
dl 0
loc 41
ccs 0
cts 23
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 11 1
A isActive() 0 4 1
A isEmailConfirmed() 0 4 1
A setEmailConfirmed() 0 6 1
1
<?php
2
3
/*
4
 * HIAM module for MRDP database compatibility
5
 *
6
 * @link      https://github.com/hiqdev/hiam-mrdp
7
 * @package   hiam-mrdp
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiam\mrdp\models;
13
14
/**
15
 * Identity model for MRDP database.
16
 *
17
 * @property string $roles
18
 * @property string $seller
19
 * @property integer $seller_id
20
 */
21
class Identity extends \hiam\models\Identity
22
{
23
    public $roles;
24
    public $seller;
25
    public $seller_id;
26
    public $email_confirmed;
27
28
    protected $activeStates = ['ok', 'active'];
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function rules()
34
    {
35
        return array_merge(parent::rules(), [
36
            ['seller_id',       'integer'],
37
38
            ['seller',          'trim'],
39
            ['seller',          'string', 'min' => 2, 'max' => 64],
40
41
            ['roles',           'trim'],
42
        ]);
43
    }
44
45
    public function isActive()
46
    {
47
        return in_array($this->state, $this->activeStates, true);
48
    }
49
50
    public function isEmailConfirmed()
51
    {
52
        return $this->isActive();
53
    }
54
55
    public function setEmailConfirmed($email)
56
    {
57
        $this->state = 'ok';
58
        $this->email_confirmed = $email;
59
        $this->save();
60
    }
61
}
62