Failed Conditions
Pull Request — experimental/3.1 (#2479)
by chihiro
121:04 queued 113:52
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 0
Metric Value
dl 0
loc 30
ccs 9
cts 14
cp 0.6429
rs 10
c 0
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 1104
    public function register(Container $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
13
    {
14 1104
        if (!isset($app['twig'])) {
15
            throw new \LogicException(
16
                'You must register the TwigServiceProvider to use the TwigLintServiceProvider.'
17
            );
18
        }
19
20 1104
        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 1104
        if (!isset($app['validator.validator_service_ids'])) {
31
            $app['validator.validator_service_ids'] = [];
32
        }
33
34 1104
        $app['validator.validator_service_ids'] = array_merge(
35 1104
            $app['validator.validator_service_ids'],
36 1104
            [TwigLintValidator::class => TwigLintValidator::class]
37
        );
38
    }
39
}
40