Test Failed
Push — feature/136-make-facade-accesi... ( bdf169 )
by Chema
04:18
created

FacadeResolverAwareTrait::getFacade()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework;
6
7
use Gacela\Framework\ClassResolver\Facade\FacadeResolver;
8
9
trait FacadeResolverAwareTrait
10
{
11
    private ?AbstractFacade $facade = null;
12
13
    protected function getFacade(): AbstractFacade
14
    {
15
        if ($this->facade === null) {
16
            $this->facade = (new FacadeResolver())->resolve($this);
17
        }
18
19
        return $this->facade;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->facade could return the type null which is incompatible with the type-hinted return Gacela\Framework\AbstractFacade. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
}
22