Completed
Push — master ( e9112a...6cc2de )
by Adrien
02:31
created

Utils::getPartialInputTypeName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
     *
15
     * @param string $className
16
     *
17
     * @return string
18
     */
19 37
    public static function getTypeName(string $className): string
20
    {
21 37
        $parts = explode('\\', $className);
22
23 37
        return end($parts);
24
    }
25
26
    /**
27
     * Get the GraphQL type name for an ID type from the PHP class
28
     *
29
     * @param string $className
30
     *
31
     * @return string
32
     */
33 13
    public static function getIDTypeName(string $className): string
34
    {
35 13
        return self::getTypeName($className) . 'ID';
36
    }
37
38
    /**
39
     * Get the GraphQL type name for an Input type from the PHP class
40
     *
41
     * @param string $className
42
     *
43
     * @return string
44
     */
45 9
    public static function getInputTypeName(string $className): string
46
    {
47 9
        return self::getTypeName($className) . 'Input';
48
    }
49
50 5
    public static function getPartialInputTypeName($className)
51
    {
52 5
        return self::getTypeName($className) . 'PartialInput';
53
    }
54
}
55