Test Failed
Push — master ( 8a7ae2...79eb97 )
by Chris
06:09
created

CanBeRestrictedTrait::getConstraints()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Leonidas\Traits;
4
5
use Leonidas\Contracts\Http\ServerRequestPolicyInterface;
6
use Psr\Http\Message\ServerRequestInterface;
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