User::isDeleteAllowed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace backend\models;
3
4
use common\models\User as BaseUser;
5
6
class User extends BaseUser implements LoggableInterface
7
{
8
    const ADMIN_ID = 1;
9
10
    public function isDeleteAllowed()
11
    {
12
        return $this->id != self::ADMIN_ID;
13
    }
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public function rules()
19
    {
20
        return array_merge(parent::rules(), [
21
            [['password'], 'string', 'min' => 6],
22
            [['auth_key'], 'default', 'value' => function () {
23
                return $this->generateAuthKey();
24
            }],
25
        ]);
26
    }
27
28
    public function getPassword()
29
    {
30
        return '';
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function attributeLabels()
37
    {
38
        return [
39
            'id' => 'ID',
40
            'username' => 'UserName',
41
            'status' => 'Status',
42
            'created_at' => 'Created',
43
            'updated_at' => 'Updated',
44
        ];
45
    }
46
}
47