UrlPath::getFullPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Tkotosz\CatalogRouter\Model;
4
5
class UrlPath
6
{
7
    /**
8
     * @var string[]
9
     */
10
    private $urlKeys;
11
12
    /**
13
     * @var string
14
     */
15
    private $identifier;
16
    
17
    /**
18
     * @param string $path
19
     */
20
    public function __construct(string $path)
21
    {
22
        $this->identifier = trim($path, '/');
23
        $this->urlKeys = explode('/', $this->identifier);
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    public function getIdentifier() : string
30
    {
31
        return $this->identifier;
32
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function getFullPath() : string
38
    {
39
        return $this->getIdentifier();
40
    }
41
    
42
    /**
43
     * @return string[]
44
     */
45
    public function getAllPart() : array
46
    {
47
        return $this->urlKeys;
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function getBeginningParts() : array
54
    {
55
        return array_slice($this->urlKeys, 0, -1);
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getLastPart() : string
62
    {
63
        return end($this->urlKeys);
64
    }
65
}
66