Completed
Push — master ( 993468...5fd9a9 )
by Markus
12s queued 10s
created

TransferGenerator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Jellyfish\Transfer;
4
5
use Jellyfish\Transfer\Definition\ClassDefinitionMapLoaderInterface;
6
7
class TransferGenerator implements TransferGeneratorInterface
8
{
9
    /**
10
     * @var \Jellyfish\Transfer\Definition\ClassDefinitionMapLoaderInterface
11
     */
12
    protected $classDefinitionMapLoader;
13
14
    /**
15
     * @var array
16
     */
17
    protected $classGenerators;
18
19
    /**
20
     * @param \Jellyfish\Transfer\Definition\ClassDefinitionMapLoaderInterface $classDefinitionMapLoader
21
     * @param \Jellyfish\Transfer\Generator\ClassGeneratorInterface[] $classGenerators
22
     */
23
    public function __construct(
24
        ClassDefinitionMapLoaderInterface $classDefinitionMapLoader,
25
        array $classGenerators
26
    ) {
27
        $this->classDefinitionMapLoader = $classDefinitionMapLoader;
28
        $this->classGenerators = $classGenerators;
29
    }
30
31
    /**
32
     * @return \Jellyfish\Transfer\TransferGeneratorInterface
33
     */
34
    public function generate(): TransferGeneratorInterface
35
    {
36
        $classDefinitionMap = $this->classDefinitionMapLoader->load();
37
38
        foreach ($classDefinitionMap as $classDefinitionMapEntry) {
39
            foreach ($this->classGenerators as $classGenerator) {
40
                $classGenerator->generate($classDefinitionMapEntry);
41
            }
42
        }
43
44
        return $this;
45
    }
46
}
47