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

ContainerTestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 42.86 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 9
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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