1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace GraphQL\Doctrine; |
||
6 | |||
7 | use GraphQL\Type\Definition\LeafType; |
||
8 | |||
9 | /** |
||
10 | * A few utils |
||
11 | */ |
||
12 | abstract class Utils |
||
13 | { |
||
14 | /** |
||
15 | * Get the GraphQL type name for an output type from the PHP class |
||
16 | * |
||
17 | * @param string $className |
||
18 | * |
||
19 | * @return string |
||
20 | */ |
||
21 | 65 | public static function getTypeName(string $className): string |
|
22 | { |
||
23 | 65 | $parts = explode('\\', $className); |
|
24 | |||
25 | 65 | return end($parts); |
|
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get the GraphQL type name for a Filter type from the PHP class |
||
30 | * |
||
31 | * @param string $className |
||
32 | * @param LeafType $type |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | 29 | public static function getOperatorTypeName(string $className, LeafType $type): string |
|
37 | { |
||
38 | 29 | return preg_replace('~Type$~', '', self::getTypeName($className)) . ucfirst($type->name); |
|
1 ignored issue
–
show
Bug
introduced
by
![]() |
|||
39 | } |
||
40 | } |
||
41 |