Completed
Push — master ( a37b1d...a8a96a )
by Tobias
22:51
created

AppKernel   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 3
A registerBundles() 0 7 1
A registerContainerConfiguration() 0 4 1
A getCacheDir() 0 4 1
A serialize() 0 4 1
A unserialize() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of php-cache\cache-bundle package.
5
 *
6
 * (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Cache\CacheBundle\Tests\Functional\app;
13
14
use Symfony\Component\Config\Loader\LoaderInterface;
15
use Symfony\Component\Filesystem\Filesystem;
16
use Symfony\Component\HttpKernel\Kernel;
17
18
class AppKernel extends Kernel
19
{
20
    private $config;
21
22
    public function __construct($config)
23
    {
24
        parent::__construct('test', true);
25
26
        $fs = new Filesystem();
27
28
        if (!$fs->isAbsolutePath($config)) {
29
            $config = __DIR__.'/config/'.$config;
30
        }
31
32
        if (!file_exists($config)) {
33
            throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config));
34
        }
35
36
        $this->config = $config;
37
    }
38
39
    public function registerBundles()
40
    {
41
        return [
42
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
43
            new \Cache\CacheBundle\CacheBundle(),
44
        ];
45
    }
46
47
    public function registerContainerConfiguration(LoaderInterface $loader)
48
    {
49
        $loader->load($this->config);
50
    }
51
52
    public function getCacheDir()
53
    {
54
        return sys_get_temp_dir().'/TestBundle';
55
    }
56
57
    public function serialize()
58
    {
59
        return $this->config;
60
    }
61
62
    public function unserialize($config)
63
    {
64
        $this->__construct($config);
65
    }
66
}
67