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
Pull Request — master (#240)
by
unknown
10:45
created

DbPanel::calculateTimings()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 10
ccs 0
cts 0
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace bedezign\yii2\audit\panels;
4
5
use bedezign\yii2\audit\components\panels\DataStoragePanelTrait;
6
use Yii;
7
use yii\debug\models\search\Db;
8
use yii\grid\GridViewAsset;
9
10
/**
11
 * DbPanel
12
 * @package bedezign\yii2\audit\panels
13
 *
14
 * @method bool hasExplain()
15
 * @method int sumDuplicateQueries()
16
 */
17
class DbPanel extends \yii\debug\panels\DbPanel
18
{
19
    use DataStoragePanelTrait;
20
21
	/**
22
     * Be able to use Module Configuration for DbPanel
23
     */
24
    public function init()
25
    {
26
        $this->db = $this->module->db;
27
    }
28 3
	
29
    /**
30 3
     * @var array current database request timings
31 3
     */
32 3
    private $_timings;
33 3
34
    /**
35
     * @inheritdoc
36
     */
37
    public function getLabel()
38
    {
39 3
        $timings = $this->calculateTimings();
40
        $queryCount = count($timings);
41 3
        $queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms';
42
        return $this->getName() . ' <small>(' . $queryCount . ' / ' . $queryTime . ')</small>';
43 3
    }
44 3
45 3
    /**
46
     * @inheritdoc
47 3
     */
48 3
    public function getDetail()
49
    {
50 3
        $searchModel = new Db();
51 3
52 3
        if (!$searchModel->load(Yii::$app->request->getQueryParams())) {
53 3
            $searchModel->load($this->defaultFilter, '');
54 3
        }
55 3
56
        $models = $this->getModels();
57
        $dataProvider = $searchModel->search($models);
58 60
        $dataProvider->getSort()->defaultOrder = $this->defaultOrder;
59
60 57
        return Yii::$app->view->render('@yii/debug/views/default/panels/db/detail', [
61 60
            'panel' => $this,
62
            'dataProvider' => $dataProvider,
63
            'searchModel' => $searchModel,
64
            'hasExplain' => method_exists($this, 'hasExplain') ? $this->hasExplain() : null,
65
            'sumDuplicates' => method_exists($this, 'sumDuplicateQueries') ? $this->sumDuplicateQueries($models) : null,
0 ignored issues
show
Unused Code introduced by
The call to DbPanel::sumDuplicateQueries() has too many arguments starting with $models.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
66
        ]);
67 3
    }
68
69 3
    public function save()
70 3
    {
71
        $data = parent::save();
72
        return (isset($data['messages']) && count($data['messages']) > 0) ? $data : null;
73
    }
74
75
    /**
76
     * @inheritdoc
77 3
     */
78
    public function registerAssets($view)
79 3
    {
80 3
        GridViewAsset::register($view);
81 3
    }
82 3
83 3
    /**
84 3
     * Calculates given request profile timings.
85 3
     *
86
     * @return array timings [token, category, timestamp, traces, nesting level, elapsed time]
87
     */
88
    public function calculateTimings()
89
    {
90
        if ($this->_timings === null) {
91
            $this->_timings = [];
92
            if (isset($this->data['messages'])) {
93
                $this->_timings = Yii::getLogger()->calculateTimings($this->data['messages']);
94
            }
95
        }
96
        return $this->_timings;
97
    }
98
}