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 — feature/respect-port ( e2dffb )
by Alexander
09:09
created

PageRule   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 51
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
C createUrl() 0 23 8
B parseRequest() 0 18 5
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)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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