RewriterContainer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getIterator() 0 6 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