AuthorizationTrait::getAuthentication()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace midorikocak\nanoauth;
6
7
trait AuthorizationTrait
8
{
9
    private ?AuthenticationInterface $authentication = null;
10
11 2
    public function checkLogin(): bool
12
    {
13 2
        if ($this->authentication && !$this->authentication->isLogged()) {
14 1
            throw new UnauthorizedException();
15
        }
16
17 1
        return $this->authentication->isLogged();
0 ignored issues
show
Bug introduced by
The method isLogged() 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

17
        return $this->authentication->/** @scrutinizer ignore-call */ isLogged();

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...
18
    }
19
20 1
    public function getAuthentication(): ?AuthenticationInterface
21
    {
22 1
        return $this->authentication;
23
    }
24
25 2
    public function setAuthentication(AuthenticationInterface $auth)
26
    {
27 2
        $this->authentication = $auth;
28 2
    }
29
}
30