Passed
Push — master ( 0ac9a3...3f373d )
by Yohann
02:09
created

Request::getUri()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace mvc\core\http;
4
5
class Request
6
{
7
8
    public static function getUri(): string
9
    {
10
        $path = $_SERVER['REQUEST_URI'] ?? '/';
11
        $position = strpos($path, '?');
12
13
        if ($position === false) return $path;
14
        return substr($path, 0, $position);
15
    }
16
17
18
    public static function getMethod(): string
19
    {
20
        return strtolower($_SERVER['REQUEST_METHOD']);
21
    }
22
}
23