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::cleanData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 9
ccs 0
cts 0
cp 0
crap 12
rs 9.6666
c 1
b 1
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\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
}