Completed
Push — feature/controller ( 534c3a...e4e086 )
by René
02:20
created

Request   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 3
c 5
b 0
f 0
lcom 1
cbo 0
dl 0
loc 39
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getPath() 0 10 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Zortje\MVC\Network;
5
6
/**
7
 * Class Request
8
 *
9
 * @package Zortje\MVC\Network
10
 */
11
class Request
12
{
13
14
    /**
15
     * @var string Full URL
16
     */
17
    protected $url;
18
19
    /**
20
     * @var array POST data
21
     */
22
    protected $post;
23
24
    /**
25
     * @param string $url  URL of the request, trailing slash are removed automatically
26
     * @param array  $post URL post fields
27
     */
28 1
    public function __construct(string $url, array $post)
29
    {
30 1
        $this->url  = rtrim($url, '/');
31 1
        $this->post = $post;
32 1
    }
33
34
    /**
35
     * Get request URL path
36
     *
37
     * @return string URL path
38
     */
39 2
    public function getPath(): string
40
    {
41 2
        $path = parse_url($this->url, PHP_URL_PATH);
42
43 2
        if (is_string($path) === false) {
44 1
            $path = '';
45
        }
46
47 2
        return $path;
48
    }
49
}
50