AclConfiguration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 11
c 1
b 0
f 0
dl 0
loc 21
ccs 0
cts 12
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Api\Field;
6
7
use Ecodev\Felix\Acl\Acl;
8
use Ecodev\Felix\Acl\MultipleRoles;
9
use Ecodev\Felix\Api\Output\AclResourceConfigurationType;
10
use GraphQL\Type\Definition\EnumType;
11
use GraphQL\Type\Definition\Type;
12
13
/**
14
 * @phpstan-import-type PermissiveFieldsConfig from FieldInterface
15
 */
16
abstract class AclConfiguration
17
{
18
    /**
19
     * Return the single field configuration, including its name.
20
     *
21
     * @return PermissiveFieldsConfig
22
     */
23
    public static function build(Acl $acl, EnumType $roleType): iterable
24
    {
25
        yield 'aclConfiguration' => fn () => [
0 ignored issues
show
Bug Best Practice introduced by
The expression yield 'aclConfiguration'...tion(...) { /* ... */ } returns the type Generator which is incompatible with the documented return type Ecodev\Felix\Api\Field\PermissiveFieldsConfig.
Loading history...
26
            'name' => 'aclConfiguration',
27
            'type' => Type::nonNull(Type::listOf(Type::nonNull(_types()->get(AclResourceConfigurationType::class)))),
28
            'description' => 'User friendly configuration of the ACL',
29
            'args' => [
30
                'roles' => Type::nonNull(Type::listOf(Type::nonNull($roleType))),
31
            ],
32
            'resolve' => function ($root, array $args) use ($acl): array {
33
                $roles = $args['roles'];
34
                $result = $acl->show(new MultipleRoles($roles));
35
36
                return $result;
37
            },
38
        ];
39
    }
40
}
41