GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CallbackEnumTrait::initialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
declare(strict_types=1);
3
namespace Thunder\Platenum\Enum;
4
5
use Thunder\Platenum\Exception\PlatenumException;
6
7
/**
8
 * @template TMember
9
 * @template TValue
10
 *
11
 * @author Tomasz Kowalczyk <[email protected]>
12 1
 */
13
trait CallbackEnumTrait
14
{
15
    /** @use EnumTrait<TMember,TValue> */
16
    use EnumTrait;
17
18 2
    /** @var non-empty-array<class-string,callable():array<string,int|string>> */
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-array<class-st...ray<string,int|string>> at position 0 could not be parsed: Unknown type name 'non-empty-array' at position 0 in non-empty-array<class-string,callable():array<string,int|string>>.
Loading history...
19
    protected static $callbacks = [];
20 2
21 1
    /** @param callable():array<string,int|string> $callback */
22
    final public static function initialize(callable $callback): void
23
    {
24 2
        if(array_key_exists(static::class, static::$callbacks)) {
25 2
            throw PlatenumException::fromAlreadyInitializedCallback(static::class);
26
        }
27 3
28
        static::$callbacks[static::class] = $callback;
29 3
    }
30 3
31 2
    private static function resolve(): array
32
    {
33
        $class = static::class;
34 1
        if(false === (array_key_exists($class, static::$callbacks) && is_callable(static::$callbacks[$class]))) {
35
            throw PlatenumException::fromInvalidCallback($class);
36
        }
37
38
        return (static::$callbacks[$class])();
39
    }
40
}
41