Passed
Pull Request — master (#1)
by Yohann
06:03
created

Request   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 11 2
A getMethod() 0 3 1
1
<?php
2
3
namespace mvc\core;
4
5
class Request
6
{
7
    public function getPath(): string
8
    {
9
        $path = $_SERVER['REQUEST_URI'] ?? '/';
10
11
        $position = strpos($path, '?');
12
13
        if ($position === false) {
14
            return $path;
15
        }
16
17
        return substr($path, 0, $position);
18
    }
19
20
21
    public function getMethod(): string
22
    {
23
        return strtolower($_SERVER['REQUEST_METHOD']);
24
    }
25
}
26