AbstractActivatorDecorator::setNext()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace DICIT\Activators;
3
4
use DICIT\ActivatorDecorator;
5
use DICIT\Container;
6
use DICIT\UnbuildableServiceException;
7
use DICIT\Activator;
8
9
class AbstractActivatorDecorator implements ActivatorDecorator
10
{
11
    /**
12
     *
13
     * @var Activator
14
     */
15
    protected $wrappedActivator = null;
16
17
    public function setNext(Activator $activator)
18
    {
19
        $this->wrappedActivator = $activator;
20
        return $this;
21
    }
22
23
    public function createInstance(Container $container, $serviceName, array $serviceConfig)
24
    {
25
        $this->before($container, $serviceName, $serviceConfig);
26
        $result = $this->aroundNext($container, $serviceName, $serviceConfig);
27
        return $this->after($container, $serviceName, $serviceConfig, $result);
28
    }
29
30
    protected function before(Container $container, &$serviceName, array &$serviceConfig)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $serviceName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $serviceConfig is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    {
32
33
    }
34
35
    protected function after(Container $container, &$serviceName, array &$serviceConfig, $returnObject)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $serviceName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $serviceConfig is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        return $returnObject;
38
    }
39
40
    protected function aroundNext(Container $container, &$serviceName, array &$serviceConfig)
41
    {
42
        if ($this->wrappedActivator) {
43
            return $this->wrappedActivator->createInstance($container, $serviceName, $serviceConfig);
44
        }
45
46
        return null;
47
    }
48
}
49