Conditions | 11 |
Paths | 36 |
Total Lines | 57 |
Code Lines | 34 |
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 |
||
173 | public function createSchema(): Schema |
||
174 | { |
||
175 | $annotationReader = new AnnotationReader($this->getDoctrineAnnotationReader(), AnnotationReader::LAX_MODE); |
||
176 | $hydrator = $this->hydrator ?: new FactoryHydrator(); |
||
177 | $authenticationService = $this->authenticationService ?: new FailAuthenticationService(); |
||
178 | $authorizationService = $this->authorizationService ?: new FailAuthorizationService(); |
||
179 | $typeResolver = new TypeResolver(); |
||
180 | $cachedDocBlockFactory = new CachedDocBlockFactory($this->cache); |
||
181 | $namingStrategy = $this->namingStrategy ?: new NamingStrategy(); |
||
182 | $typeRegistry = new TypeRegistry(); |
||
183 | |||
184 | $fieldsBuilderFactory = new FieldsBuilderFactory($annotationReader, $hydrator, $authenticationService, |
||
185 | $authorizationService, $typeResolver, $cachedDocBlockFactory, $namingStrategy); |
||
186 | |||
187 | $typeGenerator = new TypeGenerator($annotationReader, $fieldsBuilderFactory, $namingStrategy, $typeRegistry, $this->container); |
||
188 | $inputTypeUtils = new InputTypeUtils($annotationReader, $namingStrategy); |
||
189 | $inputTypeGenerator = new InputTypeGenerator($inputTypeUtils, $fieldsBuilderFactory, $hydrator); |
||
190 | |||
191 | $typeMappers = []; |
||
192 | |||
193 | foreach ($this->typeNamespaces as $typeNamespace) { |
||
194 | $typeMappers[] = new GlobTypeMapper($typeNamespace, $typeGenerator, $inputTypeGenerator, $inputTypeUtils, |
||
195 | $this->container, $annotationReader, $namingStrategy, $this->cache); |
||
196 | } |
||
197 | |||
198 | foreach ($this->typeMappers as $typeMapper) { |
||
199 | $typeMappers[] = $typeMapper; |
||
200 | } |
||
201 | |||
202 | if ($typeMappers === []) { |
||
203 | throw new GraphQLException('Cannot create schema: no namespace for types found (You must call the SchemaFactory::addTypeNamespace() at least once).'); |
||
204 | } |
||
205 | |||
206 | $typeMappers[] = new PorpaginasTypeMapper(); |
||
207 | |||
208 | $compositeTypeMapper = new CompositeTypeMapper($typeMappers); |
||
209 | $recursiveTypeMapper = new RecursiveTypeMapper($compositeTypeMapper, $namingStrategy, $this->cache, $typeRegistry); |
||
210 | |||
211 | $queryProviders = []; |
||
212 | foreach ($this->controllerNamespaces as $controllerNamespace) { |
||
213 | $queryProviders[] = new GlobControllerQueryProvider($controllerNamespace, $fieldsBuilderFactory, $recursiveTypeMapper, |
||
214 | $this->container, $this->cache); |
||
215 | } |
||
216 | |||
217 | foreach ($this->queryProviders as $queryProvider) { |
||
218 | $queryProviders[] = $queryProvider; |
||
219 | } |
||
220 | |||
221 | if ($queryProviders === []) { |
||
222 | throw new GraphQLException('Cannot create schema: no namespace for controllers found (You must call the SchemaFactory::addControllerNamespace() at least once).'); |
||
223 | } |
||
224 | |||
225 | // TODO: configure ttl for cache? |
||
226 | |||
227 | $aggregateQueryProvider = new AggregateQueryProvider($queryProviders); |
||
228 | |||
229 | return new Schema($aggregateQueryProvider, $recursiveTypeMapper, $typeResolver, $this->schemaConfig); |
||
230 | } |
||
232 |
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.