NotFound   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 78
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 4
A getPath() 0 4 1
A getFullUrl() 0 4 1
A getTimestamp() 0 4 1
A getReferer() 0 4 1
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