ConfigResolverAwareTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework;
6
7
use Gacela\Framework\ClassResolver\Config\ConfigResolver;
8
9
trait ConfigResolverAwareTrait
10
{
11
    private ?AbstractConfig $config = null;
12
13 33
    public function getConfig(): AbstractConfig
14
    {
15 33
        if ($this->config === null) {
16 24
            $this->config = (new ConfigResolver())->resolve($this);
17
        }
18
19 33
        return $this->config;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->config could return the type null which is incompatible with the type-hinted return Gacela\Framework\AbstractConfig. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
}
22