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

IndexIterator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A key() 0 4 1
A getCurrentPath() 0 11 2
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