Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — 0.13 (#633)
by Jérémiah
10:30 queued 59s
created

Security   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 15
eloc 23
dl 0
loc 79
ccs 32
cts 32
cp 1
rs 10
c 1
b 0
f 0

22 Methods

Rating   Name   Duplication   Size   Complexity  
hasRole() 0 3 ?
A hp$0 ➔ getUser() 0 3 1
isAuthenticated() 0 3 ?
A hp$0 ➔ isFullyAuthenticated() 0 3 1
A hp$0 ➔ isRememberMe() 0 3 1
A hp$0 ➔ isAuthenticated() 0 3 1
__construct() 0 11 ?
A hp$0 ➔ isAnonymous() 0 3 1
getUser() 0 3 ?
A hp$0 ➔ hasAnyRole() 0 8 2
A hp$0 ➔ hasRole() 0 3 1
hasAnyRole() 0 8 ?
A hp$0 ➔ __construct() 0 11 1
isRememberMe() 0 3 ?
hasPermission() 0 3 ?
isAnonymous() 0 3 ?
isGranted() 0 3 ?
isFullyAuthenticated() 0 3 ?
A hp$0 ➔ isGranted() 0 3 1
A hp$0 ➔ hasPermission() 0 3 1
A hp$0 ➔ hasAnyPermission() 0 8 2
hasAnyPermission() 0 8 ?
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Security;
6
7
use Symfony\Component\Security\Core\Security as CoreSecurity;
8
9
final class Security
10
{
11
    private $coreSecurity;
12
13 169
    public function __construct(?CoreSecurity $security)
14
    {
15
        $this->coreSecurity = $security ?? new class() {
16
            public function isGranted(): void
17
            {
18 1
                throw new \LogicException('The "symfony/security-core" component is required.');
19
            }
20
21
            public function getUser(): void
22
            {
23 1
                throw new \LogicException('The "symfony/security-core" component is required.');
24
            }
25
        };
26 169
    }
27
28 9
    public function getUser()
29
    {
30 9
        return $this->coreSecurity->getUser();
31
    }
32
33 27
    public function isGranted($attributes, $subject = null): bool
34
    {
35 27
        return $this->coreSecurity->isGranted($attributes, $subject);
0 ignored issues
show
Unused Code introduced by
The call to anonymous//src/Security/...rity.php$0::isGranted() has too many arguments starting with $attributes. ( Ignorable by Annotation )

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

35
        return $this->coreSecurity->/** @scrutinizer ignore-call */ isGranted($attributes, $subject);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
36
    }
37
38 2
    public function hasAnyPermission($object, array $permissions): bool
39
    {
40 2
        return \array_reduce(
41 2
            $permissions,
42
            function ($isGranted, $permission) use ($object) {
43 2
                return $isGranted || $this->isGranted($permission, $object);
44 2
            },
45 2
            false
46
        );
47
    }
48
49 4
    public function hasAnyRole(array $roles): bool
50
    {
51 4
        return \array_reduce(
52 4
            $roles,
53
            function ($isGranted, $role) {
54 4
                return $isGranted || $this->isGranted($role);
55 4
            },
56 4
            false
57
        );
58
    }
59
60 2
    public function hasPermission($object, $permission): bool
61
    {
62 2
        return $this->isGranted($permission, $object);
63
    }
64
65 8
    public function hasRole($role): bool
66
    {
67 8
        return $this->isGranted($role);
68
    }
69
70 2
    public function isAnonymous(): bool
71
    {
72 2
        return $this->isGranted('IS_AUTHENTICATED_ANONYMOUSLY');
73
    }
74
75 2
    public function isAuthenticated(): bool
76
    {
77 2
        return $this->hasAnyRole(['IS_AUTHENTICATED_REMEMBERED', 'IS_AUTHENTICATED_FULLY']);
78
    }
79
80 6
    public function isFullyAuthenticated(): bool
81
    {
82 6
        return $this->isGranted('IS_AUTHENTICATED_FULLY');
83
    }
84
85 2
    public function isRememberMe(): bool
86
    {
87 2
        return $this->isGranted('IS_AUTHENTICATED_REMEMBERED');
88
    }
89
}
90