Test Failed
Push — main ( 2f8de4...07b5fa )
by Bingo
15:07
created

CommandContextFunctions   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
eloc 13
dl 0
loc 22
rs 10
c 1
b 1
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A currentUserGroups() 0 7 2
A currentUser() 0 7 2
1
<?php
2
3
namespace Jabe\Engine\Impl\El;
4
5
use Jabe\Engine\Impl\Context\Context;
6
7
class CommandContextFunctions
8
{
9
    public const CURRENT_USER = "currentUser";
10
    public const CURRENT_USER_GROUPS = "currentUserGroups";
11
12
    public static function currentUser(): ?string
13
    {
14
        $commandContext = Context::getCommandContext();
15
        if ($commandContext !== null) {
16
            return $commandContext->getAuthenticatedUserId();
17
        } else {
18
            return null;
19
        }
20
    }
21
22
    public static function currentUserGroups(): array
23
    {
24
        $commandContext = Context::getCommandContext();
25
        if ($commandContext !== null) {
26
            return $commandContext->getAuthenticatedGroupIds();
27
        } else {
28
            return null;
0 ignored issues
show
Bug Best Practice introduced by
The expression return null returns the type null which is incompatible with the type-hinted return array.
Loading history...
29
        }
30
    }
31
}
32