AuditData   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 46.15%

Importance

Changes 0
Metric Value
dl 0
loc 44
ccs 6
cts 13
cp 0.4615
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 4 1
A findEntryTypes() 0 4 1
A findForEntry() 0 4 1
A attributeLabels() 0 10 1
1
<?php
2
3
namespace bedezign\yii2\audit\models;
4
use bedezign\yii2\audit\components\db\ActiveRecord;
5
use Yii;
6
7
/**
8
 * AuditData
9
 * Extra data associated with a specific audit line. There are currently no guidelines concerning what the name/type
10
 * needs to be, this is at your own discretion.
11
 *
12
 * @property int    $id
13
 * @property int    $entry_id
14
 * @property string $type
15
 * @property string $data
16
 * @property string $created
17
 *
18
 * @property AuditEntry    $entry
19
 *
20
 * @package bedezign\yii2\audit\models
21
 */
22
class AuditData extends ActiveRecord
23
{
24
25
    /**
26
     * @inheritdoc
27
     */
28 57
    public static function tableName()
29
    {
30 57
        return '{{%audit_data}}';
31
    }
32
33
    /**
34
     * @param $entry_id
35
     * @return array
36
     */
37 3
    public static function findEntryTypes($entry_id)
38
    {
39 3
        return static::find()->select('type')->where(['entry_id' => $entry_id])->column();
40
    }
41
42
    /**
43
     * @param $entry_id
44
     * @param $type
45
     * @return array|null|\yii\db\ActiveRecord
46
     */
47 3
    public static function findForEntry($entry_id, $type)
48
    {
49 3
        return static::find()->where(['entry_id' => $entry_id, 'type' => $type])->one();
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function attributeLabels()
56
    {
57
        return [
58
            'id'        => Yii::t('audit', 'ID'),
59
            'entry_id'  => Yii::t('audit', 'Entry ID'),
60
            'created'   => Yii::t('audit', 'Created'),
61
            'message'   => Yii::t('audit', 'Type'),
62
            'code'      => Yii::t('audit', 'Data'),
63
        ];
64
    }
65
}