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

Request::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
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