BaseMongoBlameableModel   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 5
c 7
b 0
f 0
lcom 1
cbo 2
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 11 3
A findByIdentity() 0 4 1
A attributes() 0 4 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\queries\BaseMongoBlameableQuery;
16
use vistart\Models\traits\BlameableTrait;
17
18
/**
19
 * Description of BaseMongoBlameableModel
20
 *
21
 * @author vistart <[email protected]>
22
 */
23
abstract class BaseMongoBlameableModel extends BaseMongoEntityModel
24
{
25
    use BlameableTrait;
26
27
    /**
28
     * Initialize the blameable model.
29
     * If query class is not specified, [[BaseBlameableQuery]] will be taken.
30
     */
31 9
    public function init()
32
    {
33 9
        if (!is_string($this->queryClass)) {
34 5
            $this->queryClass = BaseMongoBlameableQuery::className();
35 5
        }
36 9
        if ($this->skipInit) {
37 5
            return;
38
        }
39 8
        $this->initBlameableEvents();
40 8
        parent::init();
41 8
    }
42
43
    /**
44
     * Get the query class with specified identity.
45
     * @param BaseUserModel $identity
46
     * @return BaseMongoBlameableQuery
47
     */
48 5
    public static function findByIdentity($identity = null)
49
    {
50 5
        return static::find()->byIdentity($identity);
51
    }
52
53
    /**
54
     * Because every document has a `MongoId" class, this class is no longer needed GUID feature.
55
     * @var boolean determines whether enable the GUID features.
56
     */
57
    public $guidAttribute = false;
58
    public $idAttribute = '_id';
59
60 8
    public function attributes()
61
    {
62 8
        return $this->enabledFields();
63
    }
64
}
65