CanBeRestrictedTrait::shouldBeRendered()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Leonidas\Library\Admin\Abstracts;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use WebTheory\HttpPolicy\ServerRequestPolicyInterface;
7
8
trait CanBeRestrictedTrait
9
{
10
    protected ?ServerRequestPolicyInterface $policy = null;
11
12
    public function shouldBeRendered(ServerRequestInterface $request): bool
13
    {
14
        return !isset($this->policy) || $this->policy->approvesRequest($request);
0 ignored issues
show
Bug introduced by
The method approvesRequest() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        return !isset($this->policy) || $this->policy->/** @scrutinizer ignore-call */ approvesRequest($request);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
15
    }
16
}
17