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 ( 267903...da81a8 )
by Brett
32:31 queued 25:56
created

RequestPanel::getSummary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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\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