RewriterContainer::getIterator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace byrokrat\banking\Rewriter;
6
7
/**
8
 * Container of rewriters
9
 */
10
class RewriterContainer implements \IteratorAggregate
11
{
12
    /**
13
     * @var RewriterInterface[]
14
     */
15
    private $rewriters;
16
17 4
    public function __construct(RewriterInterface ...$rewriters)
18
    {
19 4
        $this->rewriters = $rewriters;
20 4
    }
21
22
    /**
23
     * Generates all possible permutations of all possible lenghts of the rewriter set
24
     *
25
     * @return \Traversable & iterable<ChainingRewriter>
26
     */
27 141
    public function getIterator(): \Traversable
28
    {
29 141
        foreach (Permutator::getPermutations($this->rewriters) as $permutation) {
30 141
            yield new ChainingRewriter(...$permutation);
31
        }
32 58
    }
33
}
34