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   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 84.09%

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 1
dl 0
loc 77
ccs 37
cts 44
cp 0.8409
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getParams() 0 13 3
A setParams() 0 4 1
C resolve() 0 40 12
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