Passed
Push — master ( bb1ea3...0da7d5 )
by Mike
02:05
created

addProcessConfigurationPluginCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\Processor;
5
6
7
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider;
8
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface;
9
use Xervice\Processor\Business\Model\Processor\ProcessConfigurationPluginCollection;
10
11
/**
12
 * @method \Xervice\Core\Locator\Locator getLocator()
13
 */
14
class ProcessorDependencyProvider extends AbstractDependencyProvider
15
{
16
    public const PROCESS_PLUGINS      = 'processor.process.plugins';
17
    public const TRANSLATOR_FUNCTIONS = 'processor.translator.function';
18
    public const VALIDATOR_FACADE     = 'processor.validator.facade';
19
    public const ARRAY_HANDLER_FACADE = 'processor.array.handler.facade';
20
21
    /**
22
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
23
     *
24
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
25
     */
26 1
    public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface
27
    {
28 1
        $container = $this->addProcessConfigurationPluginCollection($container);
29 1
        $container = $this->addTranslatorFunctions($container);
30 1
        $container = $this->addValidatorFacade($container);
31 1
        $container = $this->addArrayHandlerFacade($container);
32
33 1
        return $container;
34
    }
35
36
    /**
37
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
38
     *
39
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
40
     */
41 1
    protected function addProcessConfigurationPluginCollection(DependencyContainerInterface $container): DependencyContainerInterface
42
    {
43
        $container[static::PROCESS_PLUGINS] = function (DependencyContainerInterface $container) {
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

43
        $container[static::PROCESS_PLUGINS] = function (/** @scrutinizer ignore-unused */ DependencyContainerInterface $container) {

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

Loading history...
44 1
            return new ProcessConfigurationPluginCollection(
45 1
                $this->getProcessConfigurationPlugins()
46
            );
47
        };
48 1
        return $container;
49
    }
50
51
    /**
52
     * @return \Xervice\Processor\Business\Dependency\ProcessConfigurationPluginInterface[]
53
     */
54
    protected function getProcessConfigurationPlugins(): array
55
    {
56
        return [];
57
    }
58
59
    /**
60
     * @return \Xervice\Processor\Business\Model\Translator\TranslatorInterface[]
61
     */
62
    protected function getTranslatorFunctions(): array
63
    {
64
        return [];
65
    }
66
67
    /**
68
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
69
     *
70
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
71
     */
72 1
    protected function addValidatorFacade(DependencyContainerInterface $container): DependencyContainerInterface
73
    {
74
        $container[static::VALIDATOR_FACADE] = function (DependencyContainerInterface $container) {
75 1
            return $container->getLocator()->validator()->facade();
0 ignored issues
show
Bug introduced by
The method facade() does not exist on Xervice\Core\Business\Mo...y\LocatorProxyInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Xervice\Core\Business\Mo...xy\AbstractLocatorProxy or Xervice\Core\Business\Mo...PersistenceLocatorProxy. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
            return $container->getLocator()->validator()->/** @scrutinizer ignore-call */ facade();
Loading history...
76
        };
77
        
78 1
        return $container;
79
    }
80
81
    /**
82
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
83
     *
84
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
85
     */
86 1
    protected function addArrayHandlerFacade(DependencyContainerInterface $container): DependencyContainerInterface
87
    {
88
        $container[static::ARRAY_HANDLER_FACADE] = function (DependencyContainerInterface $container) {
89 1
            return $container->getLocator()->arrayHandler()->facade();
90
        };
91
92 1
        return $container;
93
    }
94
95
    /**
96
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
97
     *
98
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
99
     */
100 1
    protected function addTranslatorFunctions(DependencyContainerInterface $container): DependencyContainerInterface
101
    {
102
        $container[static::TRANSLATOR_FUNCTIONS] = function (DependencyContainerInterface $container) {
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

102
        $container[static::TRANSLATOR_FUNCTIONS] = function (/** @scrutinizer ignore-unused */ DependencyContainerInterface $container) {

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

Loading history...
103 1
            return $this->getTranslatorFunctions();
104
        };
105
106 1
        return $container;
107
    }
108
}
109