Completed
Push — master ( 4eeda9...937d59 )
by
unknown
16s queued 11s
created

AppKernel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 8

Importance

Changes 0
Metric Value
wmc 7
lcom 2
cbo 8
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 0 17 2
A registerContainerConfiguration() 0 9 2
A getCacheDir() 0 8 2
A shutdown() 0 7 1
1
<?php
2
3
namespace Smartbox\CoreBundle\Tests;
4
5
use Symfony\Component\Filesystem\Filesystem;
6
use Symfony\Component\HttpKernel\Kernel;
7
use Symfony\Component\Config\Loader\LoaderInterface;
8
use Smartbox\CoreBundle\DependencyInjection\CacheDriversCompilerPass;
9
10
class AppKernel extends Kernel
11
{
12
    private $cacheDir;
13
14
    public function registerBundles()
15
    {
16
        $bundles = [
17
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
18
            new \Symfony\Bundle\MonologBundle\MonologBundle(),
19
            new \JMS\SerializerBundle\JMSSerializerBundle(),
20
            new \Smartbox\CoreBundle\SmartboxCoreBundle(),
21
        ];
22
23
        switch ($this->getEnvironment()) {
24
            case CacheDriversCompilerPass::PREDEFINED_CACHE_DRIVER_PREDIS:
25
                $bundles[] = new \Snc\RedisBundle\SncRedisBundle();
26
                break;
27
        }
28
29
        return $bundles;
30
    }
31
32
    public function registerContainerConfiguration(LoaderInterface $loader)
33
    {
34
        $config = 'config';
35
        if ('test' !== $this->getEnvironment()) {
36
            $config = 'config_'.$this->getEnvironment();
37
        }
38
39
        $loader->load($this->getRootDir().'/config/'.$config.'.yml');
40
    }
41
42
    public function getCacheDir()
43
    {
44
        if (!$this->cacheDir) {
45
            $this->cacheDir = sys_get_temp_dir().'/sbx_core_bundle_tests';
46
        }
47
48
        return $this->cacheDir;
49
    }
50
51
    public function shutdown()
52
    {
53
        parent::shutdown();
54
55
        $fs = new Filesystem();
56
        $fs->remove($this->getCacheDir());
57
    }
58
}
59