Passed
Push — master ( 95d3b3...37ba81 )
by Adrien
07:02
created

CrudPermissionsType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 31 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Output;
6
7
use Application\Acl\Acl;
8
use Application\Model\AccountingDocument;
9
use Application\Model\ExpenseClaim;
10
use GraphQL\Type\Definition\ObjectType;
11
use GraphQL\Type\Definition\ResolveInfo;
12
13
class CrudPermissionsType extends ObjectType
14
{
15 3
    public function __construct()
16
    {
17
        $config = [
18 1
            'name' => 'CrudPermissions',
19 1
            'description' => 'Describe global permissions for currently logged in user',
20
            'fields' => [
21
                'create' => [
22 1
                    'type' => self::nonNull(self::boolean()),
23 1
                    'description' => 'Whether the user can create',
24
                    'resolve' => function (array $root, array $args, $context, ResolveInfo $info): bool {
1 ignored issue
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

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

24
                    'resolve' => function (array $root, array $args, /** @scrutinizer ignore-unused */ $context, ResolveInfo $info): bool {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $info is not used and could be removed. ( Ignorable by Annotation )

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

24
                    'resolve' => function (array $root, array $args, $context, /** @scrutinizer ignore-unused */ ResolveInfo $info): bool {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

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

24
                    'resolve' => function (array $root, /** @scrutinizer ignore-unused */ array $args, $context, ResolveInfo $info): bool {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25 3
                        $contexts = $root['contexts'];
0 ignored issues
show
Unused Code introduced by
The assignment to $contexts is dead and can be removed.
Loading history...
26 3
                        $type = $root['type'];
27
28 3
                        $instance = new $type();
29
30
                        // Simulate an owner
31
//                        $instance->timestampCreation();
32
33 3
                        if ($instance instanceof AccountingDocument) {
34 3
                            $instance->setExpenseClaim(new ExpenseClaim());
35
                        }
36
37 3
                        $acl = new Acl();
38
39 3
                        return $acl->isCurrentUserAllowed($instance, 'create');
40 1
                    },
41
                ],
42
            ],
43
        ];
44
45 1
        parent::__construct($config);
46 1
    }
47
}
48