Completed
Push — master ( 33e149...329666 )
by Wachter
09:05
created

TestKernel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8
Metric Value
wmc 7
lcom 1
cbo 8
dl 0
loc 67
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 0 8 1
A registerContainerConfiguration() 0 10 2
A buildContainer() 0 10 1
A initializeContainer() 0 14 3
1
<?php
2
3
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
4
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\Config\Loader\LoaderInterface;
7
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
8
use Symfony\Component\HttpKernel\Kernel;
9
use Task\TaskBundle\TaskBundle;
10
11
class TestKernel extends Kernel
12
{
13
    const STORAGE_VAR_NAME = 'STORAGE';
14
15
    /**
16
     * @var string
17
     */
18
    private $storage;
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function registerBundles()
24
    {
25
        return [
26
            new FrameworkBundle(),
27
            new DoctrineBundle(),
28
            new TaskBundle(),
29
        ];
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function registerContainerConfiguration(LoaderInterface $loader)
36
    {
37
        $this->storage = getenv(self::STORAGE_VAR_NAME);
38
        if ($this->storage === false) {
39
            $this->storage = 'array';
40
        }
41
42
        $loader->load(sprintf('%s/config/config.yml', __DIR__));
43
        $loader->load(sprintf('%s/config/config.%s.yml', __DIR__, $this->storage));
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    protected function buildContainer()
50
    {
51
        $container = parent::buildContainer();
52
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/config'));
53
        $loader->load('services.xml');
54
55
        $container->setParameter('kernel.storage', $this->storage);
56
57
        return $container;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    protected function initializeContainer()
64
    {
65
        $fresh = false;
66
67
        $container = $this->buildContainer();
68
        $container->compile();
69
70
        $this->container = $container;
71
        $this->container->set('kernel', $this);
72
73
        if (!$fresh && $this->container->has('cache_warmer')) {
74
            $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'));
75
        }
76
    }
77
}
78
79
class TestHandler implements \Task\Handler\HandlerInterface
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
80
{
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function handle($workload)
85
    {
86
        return strrev($workload);
87
    }
88
}
89