GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5b023f...f64ce5 )
by Brett
03:38
created

AuditTrail::getParent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 6
1
<?php
2
3
namespace bedezign\yii2\audit\models;
4
5
use bedezign\yii2\audit\components\db\ActiveRecord;
6
use Yii;
7
8
/**
9
 * AuditTrail
10
 *
11
 * @property integer $id
12
 * @property integer $entry_id
13
 * @property integer $user_id
14
 * @property string  $action
15
 * @property string  $model
16
 * @property string  $model_id
17
 * @property string  $field
18
 * @property string  $new_value
19
 * @property string  $old_value
20
 * @property string  $created
21
 *
22
 * @property AuditEntry    $entry
23
 */
24
class AuditTrail extends ActiveRecord
25
{
26
27
    /**
28
     * @inheritdoc
29
     */
30 29
    public static function tableName()
31
    {
32 29
        return '{{%audit_trail}}';
33
    }
34
35
    /**
36
     * @return array customized attribute labels (name=>label)
37
     */
38 4
    public function attributeLabels()
39
    {
40
        return [
41 4
            'id'        => Yii::t('audit', 'ID'),
42 4
            'entry_id'  => Yii::t('audit', 'Entry ID'),
43 4
            'user_id'   => Yii::t('audit', 'User ID'),
44 4
            'action'    => Yii::t('audit', 'Action'),
45 4
            'model'     => Yii::t('audit', 'Type'),
46 4
            'model_id'  => Yii::t('audit', 'ID'),
47 4
            'field'     => Yii::t('audit', 'Field'),
48 4
            'old_value' => Yii::t('audit', 'Old Value'),
49 4
            'new_value' => Yii::t('audit', 'New Value'),
50 4
            'created'   => Yii::t('audit', 'Created'),
51 4
        ];
52
    }
53
54
    /**
55
     * @return \yii\db\ActiveQuery
56
     */
57 1
    public function getEntry()
58
    {
59 1
        return $this->hasOne(AuditEntry::className(), ['id' => 'entry_id']);
60
    }
61
62
    /**
63
     * @return mixed
64
     */
65 4
    public function getDiffHtml()
66
    {
67 4
        $old = explode("\n", $this->old_value);
68 4
        $new = explode("\n", $this->new_value);
69
70 4
        foreach ($old as $i => $line) {
71 4
            $old[$i] = rtrim($line, "\r\n");
72 4
        }
73 4
        foreach ($new as $i => $line) {
74 4
            $new[$i] = rtrim($line, "\r\n");
75 4
        }
76
77 4
        $diff = new \Diff($old, $new);
78 4
        return $diff->render(new \Diff_Renderer_Html_Inline);
79
    }
80
81
    /**
82
     * @return ActiveRecord|bool
83
     */
84
    public function getParent()
85
    {
86
        $parentModel = new $this->model;
87
        $parent = $parentModel::findOne($this->model_id);
88
        return $parent ? $parent : $parentModel;
89
    }
90
    
91
}
92