Utils   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperatorTypeName() 0 3 1
A getTypeName() 0 5 1
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 119
    public static function getTypeName(string $className): string
21
    {
22 119
        $parts = explode('\\', $className);
23
24 119
        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 59
    public static function getOperatorTypeName(string $className, EnumType|ScalarType $type): string
33
    {
34 59
        return preg_replace('~Type$~', '', self::getTypeName($className)) . ucfirst($type->name);
35
    }
36
}
37