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

PrimeConfigurator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 41
ccs 10
cts 14
cp 0.7143
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configurePrime() 0 6 2
A configureHydrator() 0 9 2
A __construct() 0 3 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
     * @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
}