Utils::getOperatorTypeName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 2
crap 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