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::createUrl()   C

Complexity

Conditions 8
Paths 16

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 23
rs 6.1403
cc 8
eloc 16
nc 16
nop 3
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