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

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