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.

Request::setMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Copyright 2014 Krzysztof Magosa
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
namespace KM\Saffron;
17
18
class Request
19
{
20
    protected $domain;
21
    protected $uri;
22
    protected $method;
23
    protected $https;
24
25
    /**
26
     * Returns domain or null when not set
27
     *
28
     * @return string|null
29
     */
30
    public function getDomain()
31
    {
32
        return $this->domain;
33
    }
34
35
    /**
36
     * Sets domain
37
     *
38
     * @return \KM\Saffron\Request
39
     */
40
    public function setDomain($domain)
41
    {
42
        $this->domain = $domain;
43
        return $this;
44
    }
45
46
    /**
47
     * Returns uri or null when not set
48
     *
49
     * @return string|null
50
     */
51
    public function getUri()
52
    {
53
        return $this->uri;
54
    }
55
56
    /**
57
     * Sets uri
58
     * @return \KM\Saffron\Request
59
     */
60
    public function setUri($uri)
61
    {
62
        $this->uri = $uri;
63
        return $this;
64
    }
65
66
    /**
67
     * Returns method or null when not set
68
     *
69
     * @return string|null
70
     */
71
    public function getMethod()
72
    {
73
        return $this->method;
74
    }
75
76
    /**
77
     * Sets method
78
     *
79
     * @return \KM\Saffron\Request
80
     */
81
    public function setMethod($method)
82
    {
83
        $this->method = $method;
84
        return $this;
85
    }
86
87
    /**
88
     * Returns info whether connection is secured by https
89
     *
90
     * @return bool
91
     */
92
    public function getHttps()
93
    {
94
        return $this->https;
95
    }
96
97
    /**
98
     * Sets info whether connection is secured by https
99
     * 
100
     * @param boolean $https
101
     * @return \KM\Saffron\Request
102
     */
103
    public function setHttps($https)
104
    {
105
        $this->https = $https;
106
        return $this;
107
    }
108
109
    /**
110
     * Builds request object from super globals
111
     *
112
     * @return \KM\Saffron\Request
113
     */
114
    public static function createFromGlobals()
115
    {
116
        if (isset($_SERVER['HTTP_HOST'])) {
117
            $domain = $_SERVER['HTTP_HOST'];
118
        } elseif (isset($_SERVER['SERVER_NAME'])) {
119
            $domain = $_SERVER['SERVER_NAME'];
120
        }
121
        else {
122
            $domain = '';
123
        }
124
        
125
        $instance = new static();
126
        $instance
127
            ->setUri(
128
                explode(
129
                    '?',
130
                    isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''
131
                )[0]
132
            )
133
            ->setMethod(
134
                isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'
135
            )
136
            ->setDomain($domain)
137
            ->setHttps(
138
                !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'
139
            );
140
141
        return $instance;
142
    }
143
}
144