Completed
Push — master ( 9305d9...d34e55 )
by Tarmo
46:41
created

ContainerTestCase::getContainer()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 9
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 9.6666
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Utils/Tests/ContainerTestCase.php
5
 *
6
 * @author  TLe, Tarmo Leppänen <[email protected]>
7
 */
8
namespace App\Utils\Tests;
9
10
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
13
/**
14
 * Class ContainerTestCase
15
 *
16
 * @package App\Utils\Tests;
17
 * @author  TLe, Tarmo Leppänen <[email protected]>
18
 */
19
abstract class ContainerTestCase extends KernelTestCase
20
{
21
    /**
22
     * @var ContainerInterface
23
     */
24
    private $container;
25
26
    /**
27
     * Getter method for container
28
     *
29
     * @return ContainerInterface
30
     */
31
    public function getContainer(): ContainerInterface
32
    {
33
        if (!($this->container instanceof ContainerInterface)) {
34
            self::bootKernel();
35
36
            $this->container = static::$kernel->getContainer();
37
        }
38
39
        return $this->container;
40
    }
41
}
42