RecursiveResourceIteratorIterator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCurrentResource() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the puli/repository package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Repository\Resource\Iterator;
13
14
use Puli\Repository\Api\ResourceIterator;
15
use RecursiveIteratorIterator;
16
17
/**
18
 * Iterates recursively over {@link RecursiveResourceIterator} instances.
19
 *
20
 * Use this iterator to iterate recursively over a recursive resource iterator:
21
 *
22
 * ```php
23
 * $iterator = new RecursiveResourceIteratorIterator(
24
 *     new ResourceCollectionIterator(
25
 *         $collection,
26
 *         ResourceCollectionIterator::KEY_AS_PATH | ResourceCollectionIterator::CURRENT_AS_RESOURCE
27
 *     ),
28
 *     RecursiveResourceIteratorIterator::SELF_FIRST
29
 * );
30
 *
31
 * foreach ($iterator as $path => $resource) {
32
 *     // ...
33
 * }
34
 * ```
35
 *
36
 * The configuration of this iterator works identically to its parent class
37
 * {@link RecursiveIteratorIterator}.
38
 *
39
 * @since  1.0
40
 *
41
 * @author Bernhard Schussek <[email protected]>
42
 */
43
class RecursiveResourceIteratorIterator extends RecursiveIteratorIterator implements ResourceIterator
44
{
45
    /**
46
     * Creates a new iterator.
47
     *
48
     * @param RecursiveResourceIterator $iterator The inner iterator.
49
     * @param int                       $mode     The iteration mode.
50
     * @param int                       $flags    The iteration flags.
51
     *
52
     * @see RecursiveIteratorIterator::__construct
53
     */
54 9
    public function __construct(RecursiveResourceIterator $iterator, $mode = self::LEAVES_ONLY, $flags = 0)
55
    {
56 9
        parent::__construct($iterator, $mode, $flags);
57 9
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 5
    public function getCurrentResource()
63
    {
64 5
        return $this->getInnerIterator()->getCurrentResource();
65
    }
66
}
67