Completed
Push — master ( 7c5631...14d652 )
by vistart
04:58
created

BaseRedisBlameableModel::init()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 0
crap 3
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\base\models\models;
14
15
use rhosocial\base\models\queries\BaseRedisBlameableQuery;
16
use rhosocial\base\models\traits\BlameableTrait;
17
18
/**
19
 * Description of BaseRedisBlameableModel
20
 *
21
 * @version 1.0
22
 * @author vistart <[email protected]>
23
 */
24
abstract class BaseRedisBlameableModel extends BaseRedisEntityModel
25
{
26
    use BlameableTrait;
27
28
    /**
29
     * Initialize the blameable model.
30
     * If query class is not specified, [[BaseRedisBlameableQuery]] will be taken.
31
     */
32 1
    public function init()
33
    {
34 1
        if (!is_string($this->queryClass)) {
35 1
            $this->queryClass = BaseRedisBlameableQuery::class;
36 1
        }
37 1
        if ($this->skipInit) {
38 1
            return;
39
        }
40 1
        $this->initBlameableEvents();
41 1
        parent::init();
42 1
    }
43
44
    /**
45
     * Get the query class with specified identity.
46
     * @param BaseUserModel $identity
47
     * @return BaseRedisBlameableQuery
48
     */
49
    public static function findByIdentity($identity = null)
50
    {
51
        return static::find()->byIdentity($identity);
52
    }
53
}
54