Failed Conditions
Push — experimental/3.1 ( 47a5a1...b65b3f )
by Yangsin
141:46 queued 135:28
created

TwigLintServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 64.29%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 30
ccs 9
cts 14
cp 0.6429
rs 10
c 1
b 0
f 0
wmc 4
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 27 4
1
<?php
2
3
namespace Eccube\ServiceProvider;
4
5
6
use Eccube\Form\Validator\TwigLintValidator;
7
use Pimple\Container;
8
use Pimple\ServiceProviderInterface;
9
10
class TwigLintServiceProvider implements ServiceProviderInterface
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
11
{
12 1103
    public function register(Container $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
13
    {
14 1103
        if (!isset($app['twig'])) {
15
            throw new \LogicException(
16
                'You must register the TwigServiceProvider to use the TwigLintServiceProvider.'
17
            );
18
        }
19
20 1103
        if (!isset($app['validator'])) {
21
            throw new \LogicException(
22
                'You must register the ValidatorServiceProvider to use the TwigLintServiceProvider.'
23
            );
24
        }
25
26 17
        $app[TwigLintValidator::class] = function (Container $app) {
27 17
            return new TwigLintValidator($app['twig']);
28
        };
29
30 1103
        if (!isset($app['validator.validator_service_ids'])) {
31
            $app['validator.validator_service_ids'] = [];
32
        }
33
34 1103
        $app['validator.validator_service_ids'] = array_merge(
35 1103
            $app['validator.validator_service_ids'],
36 1103
            [TwigLintValidator::class => TwigLintValidator::class]
37
        );
38
    }
39
}
40