| Conditions | 2 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 { |
|
| 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 | } |
||
| 46 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.