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 ( 8f549c...6f6f6a )
by Jérémiah
11:28
created

AuthorizationExpressionProvider::getFunctions()   B

Complexity

Conditions 6
Paths 1

Size

Total Lines 50
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 6

Importance

Changes 3
Bugs 1 Features 2
Metric Value
c 3
b 1
f 2
dl 0
loc 50
ccs 28
cts 28
cp 1
rs 8.6315
cc 6
eloc 26
nc 1
nop 0
crap 6
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 38
    public function getFunctions()
20
    {
21
        return [
22
            new ExpressionFunction('hasRole', function () {}, function (array $variables, $role) {
23 1
                return $variables['container']->get('security.authorization_checker')->isGranted($role);
24 38
            }),
25
26
            new ExpressionFunction('hasAnyRole', function () {}, function (array $variables, array $roles) {
27 1
                foreach ($roles as $role) {
28 1
                    if ($variables['container']->get('security.authorization_checker')->isGranted($role)) {
29 1
                        return true;
30
                    }
31 1
                }
32
33 1
                return false;
34 38
            }),
35
36
            new ExpressionFunction('isAnonymous', function () {}, function (array $variables) {
37 1
                return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_ANONYMOUSLY');
38 38
            }),
39
40
            new ExpressionFunction('isRememberMe', function () {}, function (array $variables) {
41 1
                return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED');
42 38
            }),
43
44
            new ExpressionFunction('isFullyAuthenticated', function () {}, function (array $variables) {
45 1
                return $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY');
46 38
            }),
47
48
            new ExpressionFunction('isAuthenticated', function () {}, function (array $variables) {
49
                return
50 1
                    $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')
51 1
                    || $variables['container']->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY');
52 38
            }),
53
54
            new ExpressionFunction('hasPermission', function () {}, function (array $variables, $object, $permission) {
55 1
                return $variables['container']->get('security.authorization_checker')->isGranted($permission, $object);
56 38
            }),
57
58 38
            new ExpressionFunction('hasAnyPermission', function () {}, function (array $variables, $object, array $permissions) {
59 1
                foreach ($permissions as $permission) {
60 1
                    if ($variables['container']->get('security.authorization_checker')->isGranted($permission, $object)) {
61 1
                        return true;
62
                    }
63 1
                }
64
65 1
                return false;
66 38
            }),
67 38
        ];
68
    }
69
}
70