FOSHttpCacheBundle   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 7
dl 0
loc 24
rs 10
c 0
b 0
f 0
ccs 10
cts 11
cp 0.9091

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 18 4
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCacheBundle;
13
14
use FOS\HttpCache\UserContext\ContextProvider;
15
use FOS\HttpCacheBundle\DependencyInjection\Compiler\HashGeneratorPass;
16
use FOS\HttpCacheBundle\DependencyInjection\Compiler\LoggerPass;
17
use FOS\HttpCacheBundle\DependencyInjection\Compiler\SessionListenerPass;
18
use FOS\HttpCacheBundle\DependencyInjection\Compiler\TagListenerPass;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\HttpKernel\Bundle\Bundle;
21
use Symfony\Component\HttpKernel\Kernel;
22
23
class FOSHttpCacheBundle extends Bundle
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 2
    public function build(ContainerBuilder $container)
29
    {
30 2
        $container->addCompilerPass(new LoggerPass());
31 2
        $container->addCompilerPass(new TagListenerPass());
32 2
        $container->addCompilerPass(new HashGeneratorPass());
33 2
        if (version_compare(Kernel::VERSION, '3.4', '>=')
34 2
            && version_compare(Kernel::VERSION, '4.1', '<')
35
        ) {
36
            $container->addCompilerPass(new SessionListenerPass());
37
        }
38
39
        // Symfony 3.3 and higher
40 2
        if (method_exists($container, 'registerForAutoconfiguration')) {
41
            $container
42 2
                ->registerForAutoconfiguration(ContextProvider::class)
43 2
                ->addTag('fos_http_cache.user_context_provider');
44
        }
45 2
    }
46
}
47