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.

DocblockEnumTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 27
ccs 14
cts 14
cp 1
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 22 5
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 DocblockEnumTrait
14 5
{
15
    /** @use EnumTrait<TMember,TValue> */
16 5
    use EnumTrait;
17 5
18 5
    private static function resolve(): array
19 1
    {
20
        $class = static::class;
21
        $doc = (new \ReflectionClass($class))->getDocComment();
22 4
        if(false === $doc) {
23 1
            throw PlatenumException::fromMissingDocblock($class);
24
        }
25
26 3
        if(\preg_match_all('~^\s+\*\s+@method\s+static\s+(?:self|static)\s+(?<key>\w+)\(\)$~m', $doc, $matches) < 1) {
27 3
            throw PlatenumException::fromEmptyDocblock($class);
28 1
        }
29
        if(\count($matches['key']) !== substr_count($doc, '@method')) {
30
            throw PlatenumException::fromMalformedDocblock($class);
31 2
        }
32
33 2
        $values = [];
34 2
        /** @var array<string,array<int,string>> $matches */
35
        foreach($matches['key'] as $key) {
36
            $values[$key] = $key;
37 2
        }
38
39
        return $values;
40
    }
41
}
42