Passed
Push — master ( a65817...cda34f )
by Mike
01:44
created

ValidatorBusinessFactory::getArrayFieldHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\Validator\Business;
5
6
7
use Xervice\ArrayHandler\Business\ArrayHandlerFacade;
8
use Xervice\ArrayHandler\Dependency\FieldHandlerPluginInterface;
9
use Xervice\Core\Business\Model\Factory\AbstractBusinessFactory;
10
use Xervice\Validator\Business\Model\ValidatorProvider;
11
use Xervice\Validator\Business\Model\ValidatorProviderInterface;
12
use Xervice\Validator\Business\Model\ValidatorType\ClosureValidator;
13
use Xervice\Validator\Business\Model\ValidatorType\IsRequired;
14
use Xervice\Validator\Business\Model\ValidatorType\IsType;
15
use Xervice\Validator\Business\Model\ValidatorType\ValidatorInterface;
16
use Xervice\Validator\Communication\Plugin\FieldHandler\FieldHandlerPlugin;
17
use Xervice\Validator\ValidatorDependencyProvider;
18
19
/**
20
 * @method \Xervice\Validator\ValidatorConfig getConfig()
21
 */
22
class ValidatorBusinessFactory extends AbstractBusinessFactory
23
{
24
    /**
25
     * @param array $configurationPlugins
26
     *
27
     * @return \Xervice\Validator\Business\Model\ValidatorProviderInterface
28
     */
29 5
    public function createValidatorProvider(array $configurationPlugins): ValidatorProviderInterface
30
    {
31 5
        return new ValidatorProvider(
32 5
            $this->getArrayHandlerFacade(),
33 5
            $configurationPlugins,
34 5
            $this->getArrayFieldHandler()
35
        );
36
    }
37
38
    /**
39
     * @return \Xervice\ArrayHandler\Dependency\FieldHandlerPluginInterface
40
     */
41 5
    public function getArrayFieldHandler(): FieldHandlerPluginInterface
42
    {
43 5
        return new FieldHandlerPlugin(
44 5
            $this->getValidatorTypePlugins()
45
        );
46
    }
47
48
    /**
49
     * @return \Xervice\Validator\Business\Model\ValidatorType\ValidatorInterface
50
     */
51 3
    public function createClosureValidator(): ValidatorInterface
52
    {
53 3
        return new ClosureValidator();
54
    }
55
56
    /**
57
     * @return \Xervice\Validator\Business\Model\ValidatorType\ValidatorInterface
58
     */
59 4
    public function createIsTypeValidator(): ValidatorInterface
60
    {
61 4
        return new IsType();
62
    }
63
64
    /**
65
     * @return \Xervice\Validator\Business\Model\ValidatorType\ValidatorInterface
66
     */
67 7
    public function createIsRequiredValidator(): ValidatorInterface
68
    {
69 7
        return new IsRequired();
70
    }
71
72
    /**
73
     * @return \Xervice\Validator\Business\Dependency\ValidatorTypePluginInterface[]
74
     */
75 5
    public function getValidatorTypePlugins(): array
76
    {
77 5
        return $this->getDependency(ValidatorDependencyProvider::VALIDATOR_TYPE_PLUGINS);
78
    }
79
80
    /**
81
     * @return \Xervice\ArrayHandler\Business\ArrayHandlerFacade
82
     */
83 5
    public function getArrayHandlerFacade(): ArrayHandlerFacade
84
    {
85 5
        return $this->getDependency(ValidatorDependencyProvider::ARRAY_HANDLER_FACADE);
86
    }
87
}