BaseConfigTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 4
b 0
f 0
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getParams() 0 3 1
A createContainer() 0 5 1
A getContainerDefinitions() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Di\Container;
9
use Yiisoft\Di\ContainerConfig;
10
11
use function dirname;
12
13
abstract class BaseConfigTest extends TestCase
14
{
15
    final protected function createContainer(array|null $params = null): Container
16
    {
17
        $config = ContainerConfig::create()->withDefinitions($this->getContainerDefinitions($params));
18
19
        return new Container($config);
20
    }
21
22
    final protected function getContainerDefinitions(array|null $params): array
23
    {
24
        if ($params === null) {
0 ignored issues
show
introduced by
The condition $params === null is always false.
Loading history...
25
            $params = $this->getParams();
26
        }
27
28
        return require dirname(__DIR__) . '/config/di.php';
29
    }
30
31
    final protected function getParams(): array
32
    {
33
        return require dirname(__DIR__) . '/config/params.php';
34
    }
35
}
36