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.
Test Setup Failed
Push — master ( e91cf6...3a6b3f )
by Alexander
10:43
created

PageRule::parseRequest()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 8.8571
cc 5
eloc 12
nc 8
nop 2
1
<?php
2
3
namespace app\modules\page\components;
4
5
use app\modules\page\models\Page;
6
use Yii;
7
use yii\web\UrlRuleInterface;
8
9
class PageRule implements UrlRuleInterface
10
{
11
    /**
12
     * @inheritdoc
13
     */
14
    public function createUrl($manager, $route, $params)
15
    {
16
        /** @var Page $model */
17
        if ($route == 'page/page/show' || $route == 'page/page/list') {
18
            $model=null;
19
            if (isset($params['model'])) {
20
                $model = $params['model'];
21
                unset($params['model']);
22
            } else {
23
                if (isset($params['id'])) {
24
                    $model = Page::findById($params['id']);
25
                    unset($params['id']);
26
                }
27
            }
28
            if (null !== $model) {
29
                $url = ($model->slug_compiled === ':mainpage:') ? '' : $model->slug_compiled;
30
                $_query = http_build_query($params);
31
                $url = (!empty($_query)) ? $url . '?' . $_query : $url;
32
                return $url;
33
            }
34
        }
35
        return false;
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function parseRequest($manager, $request)
42
    {
43
        if ($request->serverName == Yii::$app->getModule('core')->serverName
44
            && $request->port == Yii::$app->getModule('core')->serverPort
45
        ) {
46
            $_path = $request->getPathInfo();
47
        } else {
48
            $_path = $request->absoluteUrl;
49
        }
50
        $_path = !empty($_path) ? $_path : ':mainpage:';
51
        if (null !== $model = Page::getByUrlPath($_path)) {
52
            return [
53
                '/page/page/' . $model['show_type'],
54
                ['id' => $model['id']]
55
            ];
56
        }
57
        return false;
58
    }
59
}
60