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 ( d96e23...3d7113 )
by Brett
03:09
created

RequestPanel   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 91
ccs 16
cts 32
cp 0.5
rs 10
c 1
b 1
f 0
wmc 18
lcom 1
cbo 5

6 Methods

Rating   Name   Duplication   Size   Complexity  
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 1
     */
21
    public $ignoreKeys = [];
22 1
23
    /**
24
     * @inheritdoc
25
     */
26
    public function getDetail()
27
    {
28 18
        return \Yii::$app->view->render('@yii/debug/views/default/panels/request/detail', ['panel' => $this]);
29
    }
30 18
31
    /**
32
     * @inheritdoc
33 18
     */
34
    public function save()
35
    {
36
        if (Yii::$app->request instanceof \yii\console\Request) {
37
            return $this->saveCliRequest();
38
        }
39 18
        return $this->cleanData(parent::save());
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    protected function saveCliRequest()
46
    {
47
        return $this->cleanData([
48
            'flashes' => $this->getFlashes(),
49
            'statusCode' => 0,
50
            'requestHeaders' => [],
51
            'responseHeaders' => [],
52
            'route' => $this->getRoute(),
53 18
            'action' => $this->getAction(),
54
            'actionParams' => Yii::$app->request->params,
55
            'requestBody' => [],
56
            'SERVER' => empty($_SERVER) ? [] : $_SERVER,
57
            'GET' => empty($_GET) ? [] : $_GET,
58
            'POST' => empty($_POST) ? [] : $_POST,
59
            'COOKIE' => empty($_COOKIE) ? [] : $_COOKIE,
60
            'FILES' => empty($_FILES) ? [] : $_FILES,
61
            'SESSION' => empty($_SESSION) ? [] : $_SESSION,
62 6
        ]);
63
    }
64 6
65 6
    /**
66 1
     * @return null|string
67
     */
68 1
    protected function getAction()
69
    {
70
        if (Yii::$app->requestedAction) {
71
            if (Yii::$app->requestedAction instanceof InlineAction) {
72
                return get_class(Yii::$app->requestedAction->controller) . '::' . Yii::$app->requestedAction->actionMethod . '()';
73
            }
74
            return get_class(Yii::$app->requestedAction) . '::run()';
75
        }
76 6
        return null;
77
    }
78 6
79 1
    /**
80
     * @return string
81 3
     */
82
    protected function getRoute()
83
    {
84
        if (Yii::$app->requestedAction) {
85
            return Inflector::camel2id(Yii::$app->requestedAction->getUniqueId());
86
        }
87
        return Yii::$app->requestedRoute;
88
    }
89
90
    /**
91
     * @param array $data
92
     * @return array
93
     */
94
    protected function cleanData($data)
95
    {
96
        foreach ($data as $k => $v) {
97
            if (in_array($k, $this->ignoreKeys)) {
98
                $data[$k] = null;
99
            }
100
        }
101
        return $data;
102
    }
103
104
}