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::resolve()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 12
c 1
b 0
f 0
nc 5
nop 0
dl 0
loc 22
ccs 11
cts 11
cp 1
crap 5
rs 9.5555
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