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 ( 7c9800...6d277d )
by Robert
25:06
created

Request::resolve()   C

Complexity

Conditions 12
Paths 30

Size

Total Lines 40
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 31
CRAP Score 12.0043

Importance

Changes 0
Metric Value
dl 0
loc 40
ccs 31
cts 32
cp 0.9688
rs 5.1612
c 0
b 0
f 0
cc 12
eloc 29
nc 30
nop 0
crap 12.0043

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\console;
9
10
/**
11
 * The console Request represents the environment information for a console application.
12
 *
13
 * It is a wrapper for the PHP `$_SERVER` variable which holds information about the
14
 * currently running PHP script and the command line arguments given to it.
15
 *
16
 * @property array $params The command line arguments. It does not include the entry script name.
17
 *
18
 * @author Qiang Xue <[email protected]>
19
 * @since 2.0
20
 */
21
class Request extends \yii\base\Request
22
{
23
    private $_params;
24
25
26
    /**
27
     * Returns the command line arguments.
28
     * @return array the command line arguments. It does not include the entry script name.
29
     */
30 5
    public function getParams()
31
    {
32 5
        if ($this->_params === null) {
33
            if (isset($_SERVER['argv'])) {
34
                $this->_params = $_SERVER['argv'];
35
                array_shift($this->_params);
36
            } else {
37
                $this->_params = [];
38
            }
39
        }
40
41 5
        return $this->_params;
42
    }
43
44
    /**
45
     * Sets the command line arguments.
46
     * @param array $params the command line arguments
47
     */
48 5
    public function setParams($params)
49
    {
50 5
        $this->_params = $params;
51 5
    }
52
53
    /**
54
     * Resolves the current request into a route and the associated parameters.
55
     * @return array the first element is the route, and the second is the associated parameters.
56
     */
57 5
    public function resolve()
58
    {
59 5
        $rawParams = $this->getParams();
60 5
        $endOfOptionsFound = false;
61 5
        if (isset($rawParams[0])) {
62 5
            $route = array_shift($rawParams);
63
64 5
            if ($route === '--') {
65 1
                $endOfOptionsFound = true;
66 1
                $route = array_shift($rawParams);
67 1
            }
68 5
        } else {
69
            $route = '';
70
        }
71
72 5
        $params = [];
73 5
        foreach ($rawParams as $param) {
74 4
            if ($endOfOptionsFound) {
75 2
                $params[] = $param;
76 4
            } elseif ($param === '--') {
77 1
                $endOfOptionsFound = true;
78 3
            } elseif (preg_match('/^--(\w+)(?:=(.*))?$/', $param, $matches)) {
79 2
                $name = $matches[1];
80 2
                if ($name !== Application::OPTION_APPCONFIG) {
81 2
                    $params[$name] = isset($matches[2]) ? $matches[2] : true;
82 2
                }
83 3
            } elseif (preg_match('/^-(\w+)(?:=(.*))?$/', $param, $matches)) {
84 2
                $name = $matches[1];
85 2
                if (is_numeric($name)) {
86 2
                    $params[] = $param;
87 2
                } else {
88 2
                    $params['_aliases'][$name] = isset($matches[2]) ? $matches[2] : true;
89
                }
90 2
            } else {
91 3
                $params[] = $param;
92
            }
93 5
        }
94
95 5
        return [$route, $params];
96
    }
97
}
98