CrudPermissionsType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 16
dl 0
loc 30
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 28 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\AbstractModel;
9
use Application\Model\AccountingDocument;
10
use Application\Model\ExpenseClaim;
11
use GraphQL\Type\Definition\ObjectType;
12
use GraphQL\Type\Definition\ResolveInfo;
13
14
class CrudPermissionsType extends ObjectType
15
{
16 3
    public function __construct()
17
    {
18 1
        $config = [
19 1
            'name' => 'CrudPermissions',
20 1
            'description' => 'Describe global permissions for currently logged in user',
21 1
            'fields' => [
22 1
                'create' => [
23 1
                    'type' => self::nonNull(self::boolean()),
24 1
                    'description' => 'Whether the user can create',
25 1
                    'resolve' => function ($root, array $args, $context, ResolveInfo $info): bool {
0 ignored issues
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

25
                    'resolve' => function ($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

25
                    'resolve' => function ($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...
26
                        /** @var class-string<AbstractModel> $type */
27 3
                        $type = $root['type'];
28
29 3
                        $instance = new $type();
30
31 3
                        if ($instance instanceof AccountingDocument) {
32 3
                            $instance->setExpenseClaim(new ExpenseClaim());
33
                        }
34
35 3
                        $acl = new Acl();
36
37 3
                        return $acl->isCurrentUserAllowed($instance, 'create');
38 1
                    },
39 1
                ],
40 1
            ],
41 1
        ];
42
43 1
        parent::__construct($config);
44
    }
45
}
46