Failed Conditions
Push — master ( 0ef5da...6c8847 )
by Adrien
11:04 queued 07:56
created

PhpEnumType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractDescription() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Api\Enum;
6
7
use ReflectionClass;
8
use ReflectionClassConstant;
9
10
/**
11
 * Like `\GraphQL\Type\Definition\PhpEnumType` with added support for `LocalizedPhpEnumType`.
12
 */
13
final class PhpEnumType extends \GraphQL\Type\Definition\PhpEnumType
14
{
15 1
    protected function extractDescription(ReflectionClassConstant|ReflectionClass $reflection): ?string
16
    {
17 1
        if ($reflection instanceof ReflectionClassConstant) {
18 1
            $value = $reflection->getValue();
19 1
            if ($value instanceof LocalizedPhpEnumType) {
20 1
                return $reflection->getValue()->getDescription();
21
            }
22
        }
23
24 1
        return parent::extractDescription($reflection);
25
    }
26
}
27