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
Push — master ( 353bdf...180290 )
by Jérémiah
05:23
created

AuthorizationExpressionProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 69
ccs 38
cts 38
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 66 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
                }
56 27
            ),
57
58 27
            new ExpressionFunction(
59 27
                'isAuthenticated',
60
                function () {
61 1
                    return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_REMEMBERED\') || $container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_FULLY\')';
62
                }
63 27
            ),
64
65 27
            new ExpressionFunction(
66 27
                'hasPermission',
67
                function ($object, $permission) {
68 1
                    $code = sprintf('$container->get(\'security.authorization_checker\')->isGranted(%s, %s)', $permission, $object);
69
70 1
                    return $code;
71
                }
72 27
            ),
73
74 27
            new ExpressionFunction(
75 27
                'hasAnyPermission',
76 1
                function ($object, $permissions) {
77 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);
78
79 1
                    return $code;
80
                }
81 27
            ),
82 27
        ];
83
    }
84
}
85