EntityValidatorFactory::__construct()   A
last analyzed

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
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * @license See the file LICENSE for copying permission
4
 */
5
6
namespace Thorr\Persistence\Factory;
7
8
use Thorr\Persistence\DataMapper\Manager\DataMapperManager;
9
use Zend\ServiceManager\MutableCreationOptionsInterface;
10
use Zend\ServiceManager\MutableCreationOptionsTrait;
11
use Zend\Validator\ValidatorPluginManager;
12
13
class EntityValidatorFactory implements MutableCreationOptionsInterface
14
{
15
    use MutableCreationOptionsTrait;
16
17
    private $validatorClass;
18
19
    /**
20
     * @param $validatorClass
21
     */
22 4
    public function __construct($validatorClass)
23
    {
24 4
        $this->validatorClass = (string) $validatorClass;
25 4
    }
26
27 1
    public function __invoke(ValidatorPluginManager $validatorPluginManager)
28
    {
29 1
        $dmm = $validatorPluginManager->getServiceLocator()->get(DataMapperManager::class);
30
31 1
        $class = $this->validatorClass;
32
33 1
        return new $class($this->getCreationOptions(), $dmm);
34
    }
35
}
36