Completed
Push — master ( 6fe909...aff65e )
by Adrien
01:54
created

Utils::getTypeName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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