Completed
Push — feature/controller ( 08e254...534c3a )
by René
09:48
created

Request   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 88.89%

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 8
cts 9
cp 0.8889
rs 10

2 Methods

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