Passed
Push — master ( be01f4...c3c4a8 )
by Vincent
08:40
created

PrimeConfigurator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 2
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace Bdf\PrimeBundle\Configurator;
4
5
use Bdf\Prime\ServiceLocator;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
8
class PrimeConfigurator
9
{
10
    /**
11
     * @var ContainerInterface
12
     */
13
    private $container;
14
15
    /**
16
     * PrimeFactory constructor.
17
     */
18 10
    public function __construct(ContainerInterface $container)
19
    {
20 10
        $this->container = $container;
21
    }
22
23
    /**
24
     * Create the repository instance.
25
     */
26 10
    public function configurePrime(ServiceLocator $service)
27
    {
28 10
        $loader = $this->container->getParameter('prime.hydrators');
29
30 10
        if ($loader) {
31 10
            $this->configureHydrator($service, $loader);
32
        }
33
    }
34
35
    /**
36
     * Create the repository instance.
37
     */
38 10
    private function configureHydrator(ServiceLocator $service, string $loader)
39
    {
40 10
        if (is_file($loader)) {
41
            $launcher = function () use ($service, $loader) {
42
                $registry = $service->hydrators();
43
44
                include $loader;
45
            };
46
            $launcher();
47
        }
48
    }
49
}
50