AnimalEnum   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 5

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A hp$0 ➔ getValues() 0 26 1
getValues() 0 26 ?
A hp$0 ➔ getValue() 0 4 1
A getDescription() 0 3 1
A hp$0 ➔ getDeprecationReason() 0 3 1
A hp$0 ➔ getName() 0 3 1
A hp$0 ➔ getDescription() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\GraphQL\Type;
6
7
use Andi\GraphQL\Definition\Field\EnumValueInterface;
8
use Andi\GraphQL\Definition\Type\EnumTypeInterface;
9
use Andi\GraphQL\Field\EnumValue;
10
11
final class AnimalEnum implements EnumTypeInterface
12
{
13
    public const DOG = 12;
14
    public const CAT = 15;
15
16
    public function getName(): string
17
    {
18
        return 'Animal';
19
    }
20
21
    public function getDescription(): ?string
22
    {
23
        return null;
24
    }
25
26
    public function getValues(): iterable
27
    {
28
        yield new class implements EnumValueInterface {
29
            public function getName(): string
30
            {
31
                return 'dog';
32
            }
33
34
            public function getDescription(): ?string
35
            {
36
                return null;
37
            }
38
39
            public function getDeprecationReason(): ?string
40
            {
41
                return null;
42
            }
43
44
            public function getValue(): mixed
45
            {
46
                // Any php-value
47
                return AnimalEnum::DOG;
48
            }
49
        };
50
51
        yield new EnumValue(name: 'cat', value: AnimalEnum::CAT);
52
    }
53
}
54