Conditions | 11 |
Paths | 27 |
Total Lines | 33 |
Code Lines | 18 |
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 |
||
86 | protected function used($definition): void |
||
87 | { |
||
88 | if (\is_string($definition)) { |
||
89 | if (!$this->endpoint->hasType($definition)) { |
||
90 | return; |
||
91 | } |
||
92 | |||
93 | $definition = $this->endpoint->getType($definition); |
||
94 | } |
||
95 | |||
96 | if (\in_array($definition->getName(), $this->used)) { |
||
97 | return; |
||
98 | } |
||
99 | |||
100 | $this->used[] = $definition->getName(); |
||
101 | if ($definition instanceof FieldsAwareDefinitionInterface) { |
||
102 | foreach ($definition->getFields() as $field) { |
||
103 | $this->used($field->getType()); |
||
104 | foreach ($field->getArguments() as $argument) { |
||
105 | $this->used($argument->getType()); |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | |||
110 | if ($definition instanceof InterfaceDefinition) { |
||
111 | foreach ($definition->getImplementors() as $implementor) { |
||
112 | $this->used($implementor); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | if ($definition instanceof ImplementorInterface) { |
||
117 | foreach ($definition->getInterfaces() as $interface) { |
||
118 | $this->used($interface); |
||
119 | } |
||
123 |