Completed
Push — master ( e765e7...0b5840 )
by vistart
05:28
created

BaseMongoBlameableModel::findByIdentity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.name/
9
 * @copyright Copyright (c) 2016 vistart
10
 * @license https://vistart.name/license/
11
 */
12
13
namespace vistart\Models\models;
14
15
use vistart\Models\traits\BlameableTrait;
16
17
/**
18
 * Description of BaseMongoBlameableModel
19
 *
20
 * @author vistart <[email protected]>
21
 */
22
abstract class BaseMongoBlameableModel extends BaseMongoEntityModel
23
{
24
    use BlameableTrait;
25
26
    /**
27
     * Initialize the blameable model.
28
     * If query class is not specified, [[BaseBlameableQuery]] will be taken.
29
     */
30 1
    public function init()
31
    {
32 1
        if (!is_string($this->queryClass)) {
33 1
            $this->queryClass = \vistart\Models\queries\BaseMongoBlameableQuery::className();
34 1
        }
35 1
        if ($this->skipInit) {
36 1
            return;
37
        }
38 1
        $this->initBlameableEvents();
39 1
        parent::init();
40 1
    }
41
42
    /**
43
     * Get the query class with specified identity.
44
     * @param \vistart\Models\models\BaseUserModel $identity
45
     * @return \vistart\Models\queries\BaseBlameableQuery
46
     */
47 1
    public static function findByIdentity($identity = null)
48
    {
49 1
        return static::find()->byIdentity($identity);
50
    }
51
52
    /**
53
     * Because every document has a `MongoId" class, this class is no longer needed GUID feature.
54
     * @var boolean determines whether enable the GUID features.
55
     */
56
    public $guidAttribute = false;
57
    public $idAttribute = '_id';
58
    
59 1
    public function attributes()
60
    {
61 1
        return $this->enabledFields();
62
    }
63
}
64