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

AppKernel::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 16
rs 9.4285
cc 3
eloc 8
nc 4
nop 1
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