Failed Conditions
Pull Request — master (#10)
by Adrien
02:34
created

src/Utils.php (1 issue)

Labels
Severity
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\LeafType;
9
use GraphQL\Type\Definition\ScalarType;
10
11
/**
12
 * A few utils
13
 */
14
abstract class Utils
15
{
16
    /**
17
     * Get the GraphQL type name for an output type from the PHP class
18
     *
19
     * @param string $className
20
     *
21
     * @return string
22
     */
23 65
    public static function getTypeName(string $className): string
24
    {
25 65
        $parts = explode('\\', $className);
26
27 65
        return end($parts);
28
    }
29
30
    /**
31
     * Get the GraphQL type name for a Filter type from the PHP class
32
     *
33
     * @param string $className
34
     * @param EnumType|ScalarType $type
35
     *
36
     * @return string
37
     */
38 30
    public static function getOperatorTypeName(string $className, LeafType $type): string
39
    {
40 30
        return preg_replace('~Type$~', '', self::getTypeName($className)) . ucfirst($type->name);
1 ignored issue
show
Accessing name on the interface GraphQL\Type\Definition\LeafType suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
41
    }
42
}
43