TransformationPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
c 0
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace hanneskod\readmetester\Compiler\Pass;
6
7
use hanneskod\readmetester\Compiler\CompilerPassInterface;
8
use hanneskod\readmetester\Compiler\TransformationInterface;
9
use hanneskod\readmetester\Example\ArrayExampleStore;
10
use hanneskod\readmetester\Example\ExampleStoreInterface;
11
12
/**
13
 * Perform example transformations
14
 */
15
final class TransformationPass implements CompilerPassInterface
16
{
17
    public function process(ExampleStoreInterface $store): ExampleStoreInterface
18
    {
19
        $examples = [];
20
21
        foreach ($store->getExamples() as $example) {
22
            foreach ($example->getAttributes() as $attribute) {
23
                if ($attribute instanceof TransformationInterface) {
24
                    $example = $attribute->transform($example);
25
                }
26
            }
27
28
            $examples[] = $example;
29
        }
30
31
        return new ArrayExampleStore($examples);
32
    }
33
}
34