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

Completed
Pull Request — master (#73)
by Jérémiah
07:13
created

AuthorizationExpressionProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 97.5%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 71
ccs 39
cts 40
cp 0.975
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 68 1
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\ExpressionLanguage;
13
14
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
15
16
class AuthorizationExpressionProvider implements ExpressionFunctionProviderInterface
17
{
18 27
    public function getFunctions()
19
    {
20
        return [
21 27
            new ExpressionFunction(
22 27
                'hasRole',
23
                function ($role) {
24 2
                    return sprintf('$container->get(\'security.authorization_checker\')->isGranted(%s)', $role);
25
                }
26 27
            ),
27
28 27
            new ExpressionFunction(
29 27
                'hasAnyRole',
30
                function ($roles) {
31 1
                    $code = sprintf('array_reduce(%s, function ($isGranted, $role) use ($container) { return $isGranted || $container->get(\'security.authorization_checker\')->isGranted($role); }, false)', $roles);
32
33 1
                    return $code;
34
                }
35 27
            ),
36
37 27
            new ExpressionFunction(
38 27
                'isAnonymous',
39
                function () {
40 1
                    return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_ANONYMOUSLY\')';
41
                }
42 27
            ),
43
44 27
            new ExpressionFunction(
45 27
                'isRememberMe',
46
                function () {
47 1
                    return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_REMEMBERED\')';
48
                }
49 27
            ),
50
51 27
            new ExpressionFunction(
52 27
                'isFullyAuthenticated',
53
                function () {
54 2
                    return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_FULLY\')';
55 27
                },
56
                function () {
0 ignored issues
show
Unused Code introduced by
The call to ExpressionFunction::__construct() has too many arguments starting with function () { }.

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.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
57
                }
58 27
            ),
59
60 27
            new ExpressionFunction(
61 27
                'isAuthenticated',
62
                function () {
63 1
                    return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_REMEMBERED\') || $container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_FULLY\')';
64
                }
65 27
            ),
66
67 27
            new ExpressionFunction(
68 27
                'hasPermission',
69
                function ($object, $permission) {
70 1
                    $code = sprintf('$container->get(\'security.authorization_checker\')->isGranted(%s, %s)', $permission, $object);
71
72 1
                    return $code;
73
                }
74 27
            ),
75
76 27
            new ExpressionFunction(
77 27
                'hasAnyPermission',
78 1
                function ($object, $permissions) {
79 1
                    $code = sprintf('array_reduce(%s, function ($isGranted, $permission) use ($container, $object) { return $isGranted || $container->get(\'security.authorization_checker\')->isGranted($permission, %s); }, false)', $permissions, $object);
80
81 1
                    return $code;
82
                }
83 27
            ),
84 27
        ];
85
    }
86
}
87