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.

RequestPanel   A
last analyzed

Complexity

Total Complexity 19

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 52.5%

Importance

Changes 0
Metric Value
dl 0
loc 99
ccs 21
cts 40
cp 0.525
rs 10
c 0
b 0
f 0
wmc 19
lcom 1
cbo 5

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getSummary() 0 4 1
A getDetail() 0 4 1
A save() 0 7 2
B saveCliRequest() 0 19 7
A getAction() 0 10 3
A getRoute() 0 7 2
A cleanData() 0 9 3
1
<?php
2
3
namespace bedezign\yii2\audit\panels;
4
5
use bedezign\yii2\audit\components\panels\DataStoragePanelTrait;
6
use Yii;
7
use yii\base\InlineAction;
8
use yii\helpers\Inflector;
9
10
/**
11
 * RequestPanel
12
 * @package bedezign\yii2\audit\panels
13
 */
14
class RequestPanel extends \yii\debug\panels\RequestPanel
15
{
16
    use DataStoragePanelTrait;
17
18
    /**
19
     * @var array
20
     */
21
    public $ignoreKeys = [];
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 3
    public function getSummary()
27
    {
28 3
        return Yii::$app->view->render('panels/request/summary', ['panel' => $this]);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 57
    public function getDetail()
35
    {
36 57
        return Yii::$app->view->render('panels/request/detail', ['panel' => $this]);
37
    }
38
39 57
    /**
40
     * @inheritdoc
41
     */
42
    public function save()
43
    {
44
        if (Yii::$app->request instanceof \yii\console\Request) {
45 57
            return $this->saveCliRequest();
46
        }
47
        return $this->cleanData(parent::save());
48
    }
49
50
    /**
51
     * @return array
52
     */
53 57
    protected function saveCliRequest()
54
    {
55
        return $this->cleanData([
56
            'flashes' => $this->getFlashes(),
57
            'statusCode' => 0,
58
            'requestHeaders' => [],
59
            'responseHeaders' => [],
60
            'route' => $this->getRoute(),
61
            'action' => $this->getAction(),
62
            'actionParams' => Yii::$app->request->params,
63
            'requestBody' => [],
64
            'SERVER' => empty($_SERVER) ? [] : $_SERVER,
65
            'GET' => empty($_GET) ? [] : $_GET,
66
            'POST' => empty($_POST) ? [] : $_POST,
67
            'COOKIE' => empty($_COOKIE) ? [] : $_COOKIE,
68 6
            'FILES' => empty($_FILES) ? [] : $_FILES,
69
            'SESSION' => empty($_SESSION) ? [] : $_SESSION,
70 6
        ]);
71 6
    }
72 3
73
    /**
74 3
     * @return null|string
75
     */
76
    protected function getAction()
77
    {
78
        if (Yii::$app->requestedAction) {
79
            if (Yii::$app->requestedAction instanceof InlineAction) {
80
                return get_class(Yii::$app->requestedAction->controller) . '::' . Yii::$app->requestedAction->actionMethod . '()';
81
            }
82 6
            return get_class(Yii::$app->requestedAction) . '::run()';
83
        }
84 6
        return null;
85 3
    }
86
87 3
    /**
88
     * @return string
89
     */
90
    protected function getRoute()
91
    {
92
        if (Yii::$app->requestedAction) {
93
            return Inflector::camel2id(Yii::$app->requestedAction->getUniqueId());
94 57
        }
95
        return Yii::$app->requestedRoute;
96 57
    }
97 57
98
    /**
99
     * @param array $data
100 57
     * @return array
101 57
     */
102
    protected function cleanData($data)
103
    {
104
        foreach ($data as $k => $v) {
105
            if (in_array($k, $this->ignoreKeys)) {
106
                $data[$k] = null;
107
            }
108
        }
109
        return $data;
110
    }
111
112
}
113