Passed
Push — feature/remove-setup-as-array ( 3bb37a...da7ebe )
by Jesús
04:16 queued 36s
created

FacadeResolverAwareTrait::getFacade()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 2
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
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 1
    protected function getFacade(): AbstractFacade
14
    {
15 1
        if ($this->facade === null) {
16 1
            $this->facade = (new FacadeResolver())->resolve($this->facadeClass());
17
        }
18
19 1
        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
    /**
23
     * @return class-string
1 ignored issue
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
24
     */
25
    abstract protected function facadeClass(): string;
26
}
27