ConvertZendExpressiveService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 4
A __construct() 0 12 1
1
<?php
2
/*
3
 * Copyright (c) Manero Contributors. All rights reserved.
4
 *
5
 * Licensed under the MIT License. See LICENSE.md file in the
6
 * project root for full license information.
7
 */
8
9
namespace Manero\Service;
10
11
use Manero\Creator\FactoryBeanCreator;
12
use Manero\Creator\InvocableBeanCreator;
13
use Manero\Creator\TraitCreator;
14
15
class ConvertZendExpressiveService
16
{
17
    private $dependencies;
18
19
    public function __construct(array $dependencies, TraitCreator $trait)
20
    {
21
        $this->dependencies = array_merge(
22
            [
23
                'factories' => [],
24
                'invocables' => [],
25
                'aliases' => [],
26
            ],
27
            $dependencies
28
        );
29
30
        $this->trait = $trait;
0 ignored issues
show
Bug Best Practice introduced by
The property trait does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
    }
32
33
    public function __invoke()
34
    {
35
        foreach ($this->dependencies['factories'] as $class => $factory) {
36
            $this->trait->addCreator(new FactoryBeanCreator($this->trait, $class, $factory));
37
        }
38
39
        foreach ($this->dependencies['invocables'] as $class) {
40
            $this->trait->addCreator(new InvocableBeanCreator($this->trait, $class));
41
        }
42
43
        foreach ($this->dependencies['aliases'] as $alias => $class) {
44
            $this->trait->addAlias($alias, $class);
45
        }
46
47
        $this->trait->create();
48
    }
49
}
50