Completed
Pull Request — master (#15)
by Woody
11:29
created

ContainerFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Container\Zend;
5
6
use Auryn\Injector;
7
use Northwoods\Container\InjectorConfig;
8
use Northwoods\Container\InjectorContainer;
9
use Psr\Container\ContainerInterface;
10
11
class ContainerFactory
12
{
13 236
    /** @var Injector */
14
    private $injector;
15 236
16 236
    public function __construct(Injector $injector = null)
17
    {
18 236
        $this->injector = $injector ?? new Injector();
19
    }
20 236
21 236
    public function __invoke(InjectorConfig $config): ContainerInterface
22
    {
23 236
        $container = new InjectorContainer($this->injector);
24
25
        $config->apply($this->injector);
26
27
        $this->injector->share($container);
28
        $this->injector->alias(ContainerInterface::class, InjectorContainer::class);
29
30
        return $container;
31
    }
32
}
33