AppKernel   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 12

Importance

Changes 0
Metric Value
wmc 10
lcom 2
cbo 12
dl 0
loc 69
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 0 18 1
A getRootDir() 0 4 1
A getCacheDir() 0 4 1
A getLogDir() 0 4 1
A registerContainerConfiguration() 0 8 2
A getProjectDir() 0 16 4
1
<?php
2
3
use Symfony\Component\HttpKernel\Kernel;
4
use Symfony\Component\Config\Loader\LoaderInterface;
5
6
class AppKernel extends Kernel
7
{
8
    private $projectDir;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
9
10
    public function registerBundles()
11
    {
12
        $bundles = [
13
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
14
            new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
15
            new \Symfony\Bundle\TwigBundle\TwigBundle(),
16
            new \Symfony\Bundle\WebServerBundle\WebServerBundle(),
17
            new \Translation\Bundle\TranslationBundle(),
18
            new \AppBundle\AppBundle(),
19
20
            new \Translation\PlatformAdapter\Loco\Bridge\Symfony\TranslationAdapterLocoBundle(),
21
            new \Translation\PlatformAdapter\Flysystem\Bridge\Symfony\TranslationAdapterFlysystemBundle(),
22
            new \Translation\PlatformAdapter\PhraseApp\Bridge\Symfony\TranslationAdapterPhraseAppBundle(),
23
            new \Http\HttplugBundle\HttplugBundle(),
24
        ];
25
26
        return $bundles;
27
    }
28
29
    public function getRootDir()
30
    {
31
        return __DIR__;
32
    }
33
34
    public function getCacheDir()
35
    {
36
        return sys_get_temp_dir().'/php-translation/var/cache/'.$this->getEnvironment();
37
    }
38
39
    public function getLogDir()
40
    {
41
        return sys_get_temp_dir().'/php-translation/var/logs';
42
    }
43
44
    public function registerContainerConfiguration(LoaderInterface $loader)
45
    {
46
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
47
        $config = getcwd().'/translation.yml';
48
        if (file_exists($config)) {
49
            $loader->load($config);
50
        }
51
    }
52
53
    /**
54
     * Gets the application root dir (path of the project's LICENSE file).
55
     *
56
     * @return string The project root dir
57
     */
58
    public function getProjectDir()
59
    {
60
        if (null === $this->projectDir) {
61
            $r = new \ReflectionObject($this);
62
            $dir = $rootDir = dirname($r->getFileName());
0 ignored issues
show
Unused Code introduced by
$rootDir is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
63
            while (!file_exists($dir.'/LICENSE')) {
64
                if ($dir === dirname($dir)) {
65
                    return $this->projectDir = parent::getProjectDir();
66
                }
67
                $dir = dirname($dir);
68
            }
69
            $this->projectDir = $dir;
70
        }
71
72
        return $this->projectDir;
73
    }
74
}
75