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.
Passed
Push — master ( 871d34...713d9f )
by Steve
04:40
created

TrailPanel::getChartModel()   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 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace bedezign\yii2\audit\panels;
4
5
use bedezign\yii2\audit\components\panels\Panel;
6
use bedezign\yii2\audit\components\panels\RendersSummaryChartTrait;
7
use bedezign\yii2\audit\models\AuditTrail;
8
use bedezign\yii2\audit\models\AuditTrailSearch;
9
use Yii;
10
use yii\grid\GridViewAsset;
11
12
/**
13
 * TrailPanel
14
 * @package bedezign\yii2\audit\panels
15
 */
16
class TrailPanel extends Panel
17
{
18
    use RendersSummaryChartTrait;
19
20 33
    /**
21
     * @inheritdoc
22 33
     */
23
    public function getName()
24
    {
25
        return \Yii::t('audit', 'Trails');
26
    }
27
28 3
    /**
29
     * @inheritdoc
30 3
     */
31
    public function hasEntryData($entry)
32
    {
33
        return count($entry->trails) > 0;
34
    }
35
36 3
    /**
37
     * @inheritdoc
38 3
     */
39
    public function getLabel()
40
    {
41
        return $this->getName() . ' <small>(' . count($this->_model->trails) . ')</small>';
42
    }
43
44 3
    /**
45
     * @inheritdoc
46 3
     */
47 3
    public function getDetail()
48 3
    {
49 3
        $searchModel = new AuditTrailSearch();
50 3
        $params = \Yii::$app->request->getQueryParams();
51 3
        $params['AuditTrailSearch']['entry_id'] = $params['id'];
52
        $dataProvider = $searchModel->search($params);
53
        $dataProvider->pagination = [
54 3
            'pageSize' => 1000,
55 3
        ];
56 3
57 3
        return \Yii::$app->view->render('panels/trail/detail', [
58 3
            'panel' => $this,
59 3
            'dataProvider' => $dataProvider,
60
            'searchModel' => $searchModel,
61
        ]);
62
    }
63
64 33
    /**
65
     * @inheritdoc
66 33
     */
67 3
    public function getIndexUrl()
68
    {
69
        return ['trail/index'];
70
    }
71
72 6
    /**
73
     * @inheritdoc
74 6
     */
75 3
    protected function getChartModel()
76 3
    {
77
        return AuditTrail::className();
78
    }
79
80
    /**
81
     * @inheritdoc
82 3
     */
83
    public function getChart()
84 3
    {
85 3
        return \Yii::$app->view->render('panels/trail/chart', [
86
            'panel' => $this,
87
            'chartData' => $this->getChartData()
88
        ]);
89
    }
90 3
91
    /**
92 3
     * @inheritdoc
93 3
     */
94 3
    public function registerAssets($view)
95 3
    {
96 3
        GridViewAsset::register($view);
97 3
    }
98
99
    /**
100
     * @inheritdoc
101
     */
102
    public function cleanup($maxAge = null)
103
    {
104
        $maxAge = $maxAge !== null ? $maxAge : $this->maxAge;
105
        if ($maxAge === null)
106
            return false;
107
        return AuditTrail::deleteAll([
108
            '<=', 'created', date('Y-m-d 23:59:59', strtotime("-$maxAge days"))
109
        ]);
110
    }
111
112
}