Conditions | 11 |
Paths | 10 |
Total Lines | 26 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
42 | public function convertType(Type $type, bool $input, ?string $queryName, ?string $mutationName, string $resourceClass, ?string $property, int $depth) |
||
43 | { |
||
44 | switch ($type->getBuiltinType()) { |
||
45 | case Type::BUILTIN_TYPE_BOOL: |
||
46 | return GraphQLType::boolean(); |
||
47 | case Type::BUILTIN_TYPE_INT: |
||
48 | return GraphQLType::int(); |
||
49 | case Type::BUILTIN_TYPE_FLOAT: |
||
50 | return GraphQLType::float(); |
||
51 | case Type::BUILTIN_TYPE_STRING: |
||
52 | return GraphQLType::string(); |
||
53 | case Type::BUILTIN_TYPE_ARRAY: |
||
54 | case Type::BUILTIN_TYPE_ITERABLE: |
||
55 | return 'Iterable'; |
||
56 | case Type::BUILTIN_TYPE_OBJECT: |
||
57 | if ($input && $depth > 0) { |
||
58 | return GraphQLType::string(); |
||
59 | } |
||
60 | |||
61 | if (is_a($type->getClassName(), \DateTimeInterface::class, true)) { |
||
62 | return GraphQLType::string(); |
||
63 | } |
||
64 | |||
65 | return $this->getResourceType($type, $input, $queryName, $mutationName, $depth); |
||
66 | default: |
||
67 | return null; |
||
68 | } |
||
91 |