Completed
Push — master ( 9c1f83...0c1135 )
by Paulo Rodrigues
10:00
created

TemplatingCompilerPass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 27
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTaggedPackages() 0 4 1
A getPackagesService() 0 8 2
A setDefaultPackage() 0 10 2
1
<?php
2
3
namespace Rj\FrontendBundle\DependencyInjection\Compiler\Packages;
4
5
class TemplatingCompilerPass extends BasePackagesCompilerPass
6
{
7 19
    protected function getTaggedPackages($container)
8
    {
9 19
        return $container->findTaggedServiceIds($this->namespaceService('package.templating'));
10
    }
11
12 20
    protected function getPackagesService($container)
13
    {
14 20
        if (!$container->hasDefinition('templating.helper.assets')) {
15 1
            throw new \LogicException("The 'assets' templating helper is not registered in the container");
16
        }
17
18 19
        return $container->getDefinition('templating.helper.assets');
19
    }
20
21 13
    protected function setDefaultPackage($container)
22
    {
23 13
        parent::setDefaultPackage($container);
24
25 13
        if ($this->getPackagesService($container)->getScope() === 'request') {
26 11
            $container->getDefinition($this->namespaceService('package.fallback'))
27 11
                ->setScope('request')
28
            ;
29
        }
30 13
    }
31
}
32