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

FacadeResolverAwareTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFacade() 0 7 2
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