AerialShipSamlSPExtension   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 85.71%

Importance

Changes 9
Bugs 0 Features 1
Metric Value
wmc 5
c 9
b 0
f 1
lcom 0
cbo 7
dl 0
loc 42
ccs 24
cts 28
cp 0.8571
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 39 5
1
<?php
2
3
namespace AerialShip\SamlSPBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
9
use Symfony\Component\DependencyInjection\Reference;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
12
class AerialShipSamlSPExtension extends Extension
13
{
14 3
    public function load(array $configs, ContainerBuilder $container)
15
    {
16 3
        $config = $this->processConfiguration(new Configuration(), $configs);
17
18 2
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
19 2
        $loader->load('services.yml');
20
21
        // name of doctrine object manager to use, defaults to null, which resolves to default object manager - used in mappings compiler pass
22 2
        $container->setParameter('aerial_ship_saml_sp.model_manager_name', $config['model_manager_name']);
23
24 2
        $ssoStateEntityClass = $config['sso_state_entity_class'];
25 2
        if (!class_exists($ssoStateEntityClass)) {
26 1
            throw new \InvalidArgumentException(sprintf(
27 1
                'The option `%s` contains %s but it is not a valid class name.',
28 1
                'sso_state_entity_class',
29
                $ssoStateEntityClass
30 1
            ));
31
        }
32 1
        $container->setParameter('aerial_ship_saml_sp.state.store.sso.entity_class', $ssoStateEntityClass);
33 1
        $loader->load($config['driver'].'.yml');
34
35
        // if doctrine driver, replace the manager definition so doctrine will provide it
36 1
        if (in_array($config['driver'], array('orm', 'mongodb'))) {
37 1
            if ('orm' === $config['driver']) {
38 1
                $managerService = 'aerial_ship_saml_sp.entity_manager';
39 1
                $doctrineService = 'doctrine';
40 1
            } else {
41
                $managerService = 'aerial_ship_saml_sp.document_manager';
42
                $doctrineService = sprintf('doctrine_%s', $config['driver']);
43
            }
44 1
            $definition = $container->getDefinition($managerService);
45 1
            if (method_exists($definition, 'setFactory')) {
46 1
                $definition->setFactory(array(new Reference($doctrineService), 'getManager'));
47 1
            } else {
48
                $definition->setFactoryService($doctrineService);
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Depend...on::setFactoryService() has been deprecated with message: since version 2.6, to be removed in 3.0.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
49
                $definition->setFactoryMethod('getManager');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Depend...ion::setFactoryMethod() has been deprecated with message: since version 2.6, to be removed in 3.0.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
50
            }
51 1
        }
52 1
    }
53
}
54