Asset::setMask()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Aoe\Asdis\Domain\Model;
3
4
use Aoe\Asdis\Domain\Model\Server;
5
6
/**
7
 * Represents an asset.
8
 */
9
class Asset
10
{
11
    /**
12
     * @var string
13
     */
14
    private $originalPath;
15
16
    /**
17
     * @var string
18
     */
19
    private $normalizedPath;
20
21
    /**
22
     * @var \Aoe\Asdis\Domain\Model\Server
23
     */
24
    private $server;
25
26
    /**
27
     * The mask character in the content. eg. " or '
28
     * @var string
29
     */
30
    private $mask;
31
32
    /**
33
     * @return string
34
     */
35 8
    public function getHash()
36
    {
37 8
        return md5($this->originalPath);
38
    }
39
40
    /**
41
     * @param string $originalPath
42
     */
43 10
    public function setOriginalPath($originalPath)
44
    {
45 10
        $this->originalPath = $originalPath;
46 10
    }
47
48
    /**
49
     * @return string
50
     */
51 1
    public function getOriginalPath()
52
    {
53 1
        return $this->originalPath;
54
    }
55
56
    /**
57
     * @param string $normalizedPath
58
     */
59 5
    public function setNormalizedPath($normalizedPath)
60
    {
61 5
        $this->normalizedPath = $normalizedPath;
62 5
    }
63
64
    /**
65
     * @return string
66
     */
67 2
    public function getNormalizedPath()
68
    {
69 2
        return $this->normalizedPath;
70
    }
71
72
    /**
73
     * @return string
74
     */
75 1
    public function getPregQuotedOriginalPath()
76
    {
77 1
        return '~/?' . preg_quote($this->originalPath) . '~is';
78
    }
79
80
    /**
81
     * @return string
82
     */
83 2
    public function getMaskedPregQuotedOriginalPath()
84
    {
85 2
        $mask = preg_quote($this->getMask());
86 2
        return '~/?' . $mask . preg_quote($this->originalPath) . $mask . '~is';
87
    }
88
89
    /**
90
     * @param \Aoe\Asdis\Domain\Model\Server $server
91
     */
92 4
    public function setServer(Server $server)
93
    {
94 4
        $this->server = $server;
95 4
    }
96
97
    /**
98
     * @return \Aoe\Asdis\Domain\Model\Server
99
     */
100 3
    public function getServer()
101
    {
102 3
        return $this->server;
103
    }
104
105
    /**
106
     * @return string
107
     */
108 2
    public function getUri()
109
    {
110 2
        $domain = '';
111 2
        if (isset($this->server)) {
112 1
            $domain = $this->server->getUri();
113
        }
114 2
        return $domain . $this->normalizedPath;
115
    }
116
117
    /**
118
     * @return string
119
     */
120 3
    public function getMask()
121
    {
122 3
        return $this->mask;
123
    }
124
125
    /**
126
     * @param string $mask
127
     */
128 4
    public function setMask($mask){
129 4
        $this->mask = $mask;
130
    }
131
}