NotFound::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 12
cts 12
cp 1
rs 9.6666
c 0
b 0
f 0
cc 4
nc 8
nop 4
crap 4
1
<?php
2
3
namespace Zenstruck\RedirectBundle\Model;
4
5
/**
6
 * @author Kevin Bond <[email protected]>
7
 */
8
abstract class NotFound
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $path;
14
15
    /**
16
     * @var string
17
     */
18
    protected $fullUrl;
19
20
    /**
21
     * @var \DateTime
22
     */
23
    protected $timestamp;
24
25
    /**
26
     * @var string
27
     */
28
    protected $referer;
29
30
    /**
31
     * @param string      $path
32
     * @param string      $fullUrl
33
     * @param string|null $referer
34
     */
35 20
    public function __construct($path, $fullUrl, $referer = null, \DateTime $timestamp = null)
36
    {
37 20
        if (null === $timestamp) {
38 20
            $timestamp = new \DateTime('now');
39
        }
40
41 20
        $path = \trim($path);
42 20
        $path = !empty($path) ? $path : null;
43
44 20
        if (null !== $path) {
45 18
            $path = '/'.\ltrim(\parse_url($path, \PHP_URL_PATH), '/');
46
        }
47
48 20
        $this->path = $path;
49 20
        $this->fullUrl = $fullUrl;
50 20
        $this->referer = $referer;
51 20
        $this->timestamp = $timestamp;
52 20
    }
53
54
    /**
55
     * @return string
56
     */
57 18
    public function getPath()
58
    {
59 18
        return $this->path;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 17
    public function getFullUrl()
66
    {
67 17
        return $this->fullUrl;
68
    }
69
70
    /**
71
     * @return \DateTime
72
     */
73 16
    public function getTimestamp()
74
    {
75 16
        return $this->timestamp;
76
    }
77
78
    /**
79
     * @return string|null
80
     */
81 17
    public function getReferer()
82
    {
83 17
        return $this->referer;
84
    }
85
}
86