PathRecorder::current()   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
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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