Failed Conditions
Push — master ( 05fc61...964283 )
by Adrien
02:24
created

Utils::getRecursiveClassAnnotations()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
rs 9.9332
c 0
b 0
f 0
ccs 11
cts 11
cp 1
cc 4
nc 8
nop 3
crap 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Doctrine;
6
7
use GraphQL\Type\Definition\EnumType;
8
use GraphQL\Type\Definition\ScalarType;
9
10
/**
11
 * A few utils.
12
 */
13
abstract class Utils
14
{
15
    /**
16
     * Get the GraphQL type name for an output type from the PHP class.
17
     *
18
     * @param class-string $className
19
     */
20 108
    public static function getTypeName(string $className): string
21
    {
22 108
        $parts = explode('\\', $className);
23
24 108
        return end($parts);
25
    }
26
27
    /**
28
     * Get the GraphQL type name for a Filter type from the PHP class.
29
     *
30
     * @param class-string $className
31
     */
32 58
    public static function getOperatorTypeName(string $className, EnumType|ScalarType $type): string
33
    {
34 58
        return preg_replace('~Type$~', '', self::getTypeName($className)) . ucfirst($type->name);
35
    }
36
}
37