Completed
Push — master ( 65570c...bf6ec7 )
by Arne
03:29 queued 12s
created

IndexIterator::__construct()   A

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 1
1
<?php
2
3
namespace Storeman\Index;
4
5
class IndexIterator extends \RecursiveIteratorIterator
6
{
7
    public function __construct(RecursiveIndexIterator $indexIterator)
8
    {
9
        parent::__construct($indexIterator, \RecursiveIteratorIterator::SELF_FIRST);
10
    }
11
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function key()
16
    {
17
        return $this->getCurrentPath();
18
    }
19
20
    /**
21
     * Returns the current objects path.
22
     *
23
     * @return string
24
     */
25
    protected function getCurrentPath(): string
26
    {
27
        $parts = [];
28
29
        for ($level = 0; $level <= $this->getDepth(); $level++)
30
        {
31
            $parts[] = $this->getSubIterator($level)->key();
32
        }
33
34
        return implode('/', $parts);
35
    }
36
}
37