We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 11 |
Paths | 10 |
Total Lines | 52 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
47 | public function guessType(ReflectionClass $reflectionClass, Reflector $reflector, array $filterGraphQLTypes = []): ?string |
||
48 | { |
||
49 | if (!$reflector instanceof ReflectionProperty) { |
||
50 | throw new TypeGuessingException('Doctrine type guesser only apply to properties'); |
||
51 | } |
||
52 | /** @var Column|null $columnAnnotation */ |
||
53 | $columnAnnotation = $this->getAnnotation($reflector, Column::class); |
||
54 | |||
55 | if (null !== $columnAnnotation) { |
||
56 | $type = $this->resolveTypeFromDoctrineType($columnAnnotation->type); |
||
57 | $nullable = $columnAnnotation->nullable; |
||
58 | if ($type) { |
||
59 | return $nullable ? $type : sprintf('%s!', $type); |
||
60 | } else { |
||
61 | throw new TypeGuessingException(sprintf('Unable to auto-guess GraphQL type from Doctrine type "%s"', $columnAnnotation->type)); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | $associationAnnotations = [ |
||
66 | OneToMany::class => true, |
||
67 | OneToOne::class => false, |
||
68 | ManyToMany::class => true, |
||
69 | ManyToOne::class => false, |
||
70 | ]; |
||
71 | |||
72 | foreach ($associationAnnotations as $associationClass => $isMultiple) { |
||
73 | /** @var OneToMany|OneToOne|ManyToMany|ManyToOne|null $associationAnnotation */ |
||
74 | $associationAnnotation = $this->getAnnotation($reflector, $associationClass); |
||
75 | if (null !== $associationAnnotation) { |
||
76 | $target = $this->fullyQualifiedClassName($associationAnnotation->targetEntity, $reflectionClass->getNamespaceName()); |
||
77 | $type = $this->map->resolveType($target, ['type']); |
||
78 | |||
79 | if ($type) { |
||
80 | $isMultiple = $associationAnnotations[get_class($associationAnnotation)]; |
||
81 | if ($isMultiple) { |
||
82 | return sprintf('[%s]!', $type); |
||
83 | } else { |
||
84 | $isNullable = false; |
||
85 | /** @var JoinColumn|null $joinColumn */ |
||
86 | $joinColumn = $this->getAnnotation($reflector, JoinColumn::class); |
||
87 | if (null !== $joinColumn) { |
||
88 | $isNullable = $joinColumn->nullable; |
||
89 | } |
||
90 | |||
91 | return sprintf('%s%s', $type, $isNullable ? '' : '!'); |
||
92 | } |
||
93 | } else { |
||
94 | throw new TypeGuessingException(sprintf('Unable to auto-guess GraphQL type from Doctrine target class "%s" (check if the target class is a GraphQL type itself (with a @Metadata\Type metadata).', $target)); |
||
95 | } |
||
96 | } |
||
97 | } |
||
98 | throw new TypeGuessingException(sprintf('No Doctrine ORM annotation found.')); |
||
99 | } |
||
177 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.