ValidatorDependencyProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 47
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addArrayHandlerFacade() 0 6 1
A addValidatorTypePlugins() 0 11 1
A handleDependencies() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\Validator;
5
6
7
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider;
8
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface;
9
use Xervice\Validator\Communication\Plugin\ValidatorType\ClosureValidatorPlugin;
10
use Xervice\Validator\Communication\Plugin\ValidatorType\IsRequiredPlugin;
11
use Xervice\Validator\Communication\Plugin\ValidatorType\IsTypePlugin;
12
13
/**
14
 * @method \Xervice\Core\Locator\Locator getLocator()
15
 */
16
class ValidatorDependencyProvider extends AbstractDependencyProvider
17
{
18
    public const VALIDATOR_TYPE_PLUGINS = 'validator.type.plugins';
19
    public const ARRAY_HANDLER_FACADE = 'validator.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 2
    public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface
27
    {
28 2
        $container = $this->addValidatorTypePlugins($container);
29 2
        $container = $this->addArrayHandlerFacade($container);
30
31 2
        return $container;
32
    }
33
34
    /**
35
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
36
     *
37
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
38
     */
39 2
    protected function addValidatorTypePlugins(DependencyContainerInterface $container): DependencyContainerInterface
40
    {
41
        $container[static::VALIDATOR_TYPE_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

41
        $container[static::VALIDATOR_TYPE_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...
42
            return [
43 1
                new IsRequiredPlugin(),
44 1
                new IsTypePlugin(),
45 1
                new ClosureValidatorPlugin()
46
            ];
47
        };
48
49 2
        return $container;
50
    }
51
52
    /**
53
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
54
     *
55
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
56
     */
57 2
    protected function addArrayHandlerFacade(DependencyContainerInterface $container): DependencyContainerInterface
58
    {
59
        $container[static::ARRAY_HANDLER_FACADE] = function (DependencyContainerInterface $container) {
60 1
            return $container->getLocator()->arrayHandler()->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

60
            return $container->getLocator()->arrayHandler()->/** @scrutinizer ignore-call */ facade();
Loading history...
61
        };
62 2
        return $container;
63
}
64
}
65