CrudPermissionsType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 23
ccs 18
cts 18
cp 1
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 GraphQL\Type\Definition\ObjectType;
10
use GraphQL\Type\Definition\ResolveInfo;
11
12
class CrudPermissionsType extends ObjectType
13
{
14 3
    public function __construct()
15
    {
16 1
        $config = [
17 1
            'name' => 'CrudPermissions',
18 1
            'description' => 'Describe global permissions for currently logged in user',
19 1
            'fields' => [
20 1
                'create' => [
21 1
                    'type' => self::nonNull(self::boolean()),
22 1
                    'description' => 'Whether the user can create',
23 1
                    'resolve' => function ($root, array $args, $context, ResolveInfo $info): bool {
0 ignored issues
show
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

23
                    '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...
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

23
                    '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...
24
                        /** @var class-string<AbstractModel> $type */
25 3
                        $type = $root['type'];
26
27 3
                        $instance = new $type();
28 3
                        $acl = new Acl();
29
30 3
                        return $acl->isCurrentUserAllowed($instance, 'create');
31 1
                    },
32 1
                ],
33 1
            ],
34 1
        ];
35
36 1
        parent::__construct($config);
37
    }
38
}
39