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 ( 4f5669...8f549c )
by Jérémiah
07:08
created

AuthorizationExpressionProvider   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 23.91%

Importance

Changes 2
Bugs 1 Features 2
Metric Value
wmc 8
c 2
b 1
f 2
lcom 0
cbo 1
dl 0
loc 81
ccs 11
cts 46
cp 0.2391
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C getFunctions() 0 78 8
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\ExpressionFunction;
15
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
16
17
class AuthorizationExpressionProvider implements ExpressionFunctionProviderInterface
18
{
19 24
    public function getFunctions()
20
    {
21
        return [
22
            new ExpressionFunction('hasRole', function ($role) {
23
                return sprintf('$authChecker->isGranted(%s)', $role);
24
            }, function (array $variables, $role) {
25
                return $variables['container']->get('security.authorization_checker')->isGranted($role);
26 24
            }),
27
28
            new ExpressionFunction('hasAnyRole', function (array $roles) {
29
                $compiler = 'false';
30
                foreach ($roles as $role) {
31
                    $compiler .= ' || ';
32
                    $compiler .= sprintf('$authChecker->isGranted(%s)', $role);
33
                }
34
35
                return $compiler;
36
            }, function (array $variables, array $roles) {
37
                foreach ($roles as $role) {
38
                    if ($variables['container']->get('security.authorization_checker')->isGranted($role)) {
39
                        return true;
40
                    }
41
                }
42
43
                return false;
44 24
            }),
45
46
            new ExpressionFunction('isAnonymous', function () {
47
                return '$authChecker->isGranted("IS_AUTHENTICATED_ANONYMOUSLY")';
48
            }, function (array $variables) {
49
                return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_ANONYMOUSLY');
50 24
            }),
51
52
            new ExpressionFunction('isRememberMe', function () {
53
                return '$authChecker->isGranted("IS_AUTHENTICATED_REMEMBERED")';
54
            }, function (array $variables) {
55
                return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED');
56 24
            }),
57
58
            new ExpressionFunction('isFullyAuthenticated', function () {
59
                return sprintf('$authChecker->isGranted("IS_AUTHENTICATED_FULLY")');
60
            }, function (array $variables) {
61
                return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY');
62 24
            }),
63
64
            new ExpressionFunction('isAuthenticated', function () {
65
                return '$authChecker->isGranted("IS_AUTHENTICATED_REMEMBERED") ||  $authChecker->isGranted("IS_AUTHENTICATED_FULLY")';
66
            }, function (array $variables) {
67
                return
68
                    $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')
69
                    || $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY');
70 24
            }),
71
72
            new ExpressionFunction('hasPermission', function ($object, $permission) {
73
                return sprintf('$authChecker->isGranted(%s, $object)', $permission);
74
            }, function (array $variables, $object, $permission) {
75
                return $variables['container']->get('security.authorization_checker')->isGranted($permission, $object);
76 24
            }),
77
78
            new ExpressionFunction('hasAnyPermission', function ($object, array $permissions) {
79
                $compiler = 'false';
80
                foreach ($permissions as $permission) {
81
                    $compiler .= ' || ';
82
                    $compiler .= sprintf('$authChecker->isGranted("%s", $object)', $permission);
83
                }
84
85
                return $compiler;
86 24
            }, function (array $variables, $object, array $permissions) {
87
                foreach ($permissions as $permission) {
88
                    if ($variables['container']->get('security.authorization_checker')->isGranted($permission, $object)) {
89
                        return true;
90
                    }
91
                }
92
93
                return false;
94 24
            }),
95 24
        ];
96
    }
97
}
98