Passed
Pull Request — master (#3)
by Vincent
08:42
created

PrimeConfigurator::configurePrime()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
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
     * @param ContainerInterface $container
19
     */
20 8
    public function __construct(ContainerInterface $container)
21
    {
22 8
        $this->container = $container;
23 8
    }
24
25
    /**
26
     * Create the repository instance
27
     */
28 8
    public function configurePrime(ServiceLocator $service)
29
    {
30 8
        $loader = $this->container->getParameter('prime.hydrators');
31
32 8
        if ($loader) {
33 8
            $this->configureHydrator($service, $loader);
34
        }
35 8
    }
36
37
    /**
38
     * Create the repository instance
39
     */
40 8
    private function configureHydrator(ServiceLocator $service, string $loader)
41
    {
42 8
        if (is_file($loader)) {
43
            $launcher = function() use($service, $loader) {
44
                $registry = $service->hydrators();
45
46
                include $loader;
47
            };
48
            $launcher();
49
        }
50
    }
51
}