Passed
Pull Request — master (#9)
by Pavel
05:47
created

Kernel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Bankiru\Api\Rpc\Test;
4
5
use Bankiru\Api\Rpc\BankiruRpcServerBundle;
6
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
7
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
8
use Symfony\Bundle\SecurityBundle\SecurityBundle;
9
use Symfony\Component\Config\Loader\LoaderInterface;
10
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
11
12
final class Kernel extends BaseKernel
13
{
14 12
    public function __construct($environment, $debug)
15
    {
16 12
        @unlink($this->getCacheDir());
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
17 12
        @unlink($this->getLogDir());
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
18 12
        parent::__construct($environment, $debug);
19 12
    }
20
21 12
    public function getCacheDir()
22
    {
23 12
        return __DIR__ . '/../../build/' . $this->getName() . '/cache';
24
    }
25
26 12
    public function getLogDir()
27
    {
28 12
        return __DIR__ . '/../../build/' . $this->getName() . '/log';
29
    }
30
31
    /** {@inheritdoc} */
32 12
    public function registerBundles()
33
    {
34
        return [
35 12
            new SensioFrameworkExtraBundle(),
36 12
            new FrameworkBundle(),
37 12
            new BankiruRpcServerBundle(),
38 12
            new SecurityBundle(),
39 12
        ];
40
    }
41
42 12
    public function getName()
43
    {
44 12
        return 'rpc_test';
45
    }
46
47
    /** {@inheritdoc} */
48 1
    public function registerContainerConfiguration(LoaderInterface $loader)
49
    {
50 1
        $loader->load(__DIR__ . '/config/test.yml');
51 1
    }
52
}
53