PathRecorder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 56
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A moveTo() 0 4 1
A moveParent() 0 4 1
A current() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of file-fixture.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace holyshared\fixture;
13
14
final class PathRecorder
15
{
16
17
    /**
18
     * @var string[]
19
     */
20
    private $path = [];
21
22
    /**
23
     * @var string
24
     */
25
    private $pathSegment;
26
27
    /**
28
     * @param string $pathSegment
29
     */
30
    public function __construct($pathSegment = ':')
31
    {
32
        $this->path = [];
33
        $this->pathSegment = $pathSegment;
34
    }
35
36
    /**
37
     * Move to the path of the specified name
38
     *
39
     * @param string $path
40
     */
41
    public function moveTo($path)
42
    {
43
        $this->path[] = $path;
44
    }
45
46
    /**
47
     * Move to the path of parent
48
     */
49
    public function moveParent()
50
    {
51
        array_pop($this->path);
52
    }
53
54
    /**
55
     * Get the path of current
56
     *
57
     * @return string
58
     */
59
    public function current()
60
    {
61
        return implode($this->path, $this->pathSegment);
62
    }
63
64
    public function __toString()
65
    {
66
        return $this->current();
67
    }
68
69
}
70