Completed
Push — master ( 8f233e...cb7239 )
by Tobias
45:50 queued 28:37
created

AppKernel   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 8
c 2
b 1
f 1
lcom 1
cbo 5
dl 0
loc 49
rs 10
1
<?php
2
3
namespace Happyr\GoogleAnalyticsBundle\Tests\Functional\app;
4
5
use Symfony\Component\Config\Loader\LoaderInterface;
6
use Symfony\Component\Filesystem\Filesystem;
7
use Symfony\Component\HttpKernel\Kernel;
8
9
class AppKernel extends Kernel
10
{
11
    private $config;
12
13
    public function __construct($config)
14
    {
15
        parent::__construct('test', true);
16
17
        $fs = new Filesystem();
18
19
        if (!$fs->isAbsolutePath($config)) {
20
            $config = __DIR__.'/config/'.$config;
21
        }
22
23
        if (!file_exists($config)) {
24
            throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config));
25
        }
26
27
        $this->config = $config;
28
    }
29
30
    public function registerBundles()
31
    {
32
        return [
33
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
34
            new \Happyr\GoogleAnalyticsBundle\HappyrGoogleAnalyticsBundle(),
35
        ];
36
    }
37
38
    public function registerContainerConfiguration(LoaderInterface $loader)
39
    {
40
        $loader->load($this->config);
41
    }
42
43
    public function getCacheDir()
44
    {
45
        return sys_get_temp_dir().'/TestBundle';
46
    }
47
48
    public function serialize()
49
    {
50
        return $this->config;
51
    }
52
53
    public function unserialize($config)
54
    {
55
        $this->__construct($config);
56
    }
57
}
58