| Total Lines | 54 |
| Code Lines | 36 |
| 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 |
||
| 44 | public function setUp() |
||
| 45 | { |
||
| 46 | $this->mainContainer = new Picotainer([ |
||
| 47 | Schema::class => function(ContainerInterface $container) { |
||
| 48 | return new Schema($container->get(QueryProviderInterface::class), $container->get(RecursiveTypeMapperInterface::class)); |
||
| 49 | }, |
||
| 50 | QueryProviderInterface::class => function(ContainerInterface $container) { |
||
| 51 | return new GlobControllerQueryProvider('TheCodingMachine\\GraphQL\\Controllers\\Fixtures\\Integration\\Controllers', $container->get(ControllerQueryProviderFactory::class), |
||
| 52 | $container->get(RecursiveTypeMapperInterface::class), $container->get(BasicAutoWiringContainer::class), new NullCache()); |
||
| 53 | }, |
||
| 54 | ControllerQueryProviderFactory::class => function(ContainerInterface $container) { |
||
| 55 | return new ControllerQueryProviderFactory( |
||
| 56 | $container->get(AnnotationReader::class), |
||
| 57 | $container->get(HydratorInterface::class), |
||
| 58 | $container->get(AuthenticationServiceInterface::class), |
||
| 59 | $container->get(AuthorizationServiceInterface::class), |
||
| 60 | $container->get(BasicAutoWiringContainer::class) |
||
| 61 | ); |
||
| 62 | }, |
||
| 63 | BasicAutoWiringContainer::class => function(ContainerInterface $container) { |
||
|
|
|||
| 64 | return new BasicAutoWiringContainer(new EmptyContainer()); |
||
| 65 | }, |
||
| 66 | AuthorizationServiceInterface::class => function(ContainerInterface $container) { |
||
| 67 | return new VoidAuthorizationService(); |
||
| 68 | }, |
||
| 69 | AuthenticationServiceInterface::class => function(ContainerInterface $container) { |
||
| 70 | return new VoidAuthenticationService(); |
||
| 71 | }, |
||
| 72 | RecursiveTypeMapperInterface::class => function(ContainerInterface $container) { |
||
| 73 | return new RecursiveTypeMapper($container->get(TypeMapperInterface::class)); |
||
| 74 | }, |
||
| 75 | TypeMapperInterface::class => function(ContainerInterface $container) { |
||
| 76 | return new GlobTypeMapper('TheCodingMachine\\GraphQL\\Controllers\\Fixtures\\Integration\\Types', |
||
| 77 | $container->get(TypeGenerator::class), |
||
| 78 | $container->get(BasicAutoWiringContainer::class), |
||
| 79 | $container->get(AnnotationReader::class), |
||
| 80 | new NullCache() |
||
| 81 | ); |
||
| 82 | }, |
||
| 83 | TypeGenerator::class => function(ContainerInterface $container) { |
||
| 84 | return new TypeGenerator( |
||
| 85 | $container->get(AnnotationReader::class), |
||
| 86 | $container->get(ControllerQueryProviderFactory::class) |
||
| 87 | ); |
||
| 88 | }, |
||
| 89 | AnnotationReader::class => function(ContainerInterface $container) { |
||
| 90 | return new AnnotationReader(new DoctrineAnnotationReader()); |
||
| 91 | }, |
||
| 92 | HydratorInterface::class => function(ContainerInterface $container) { |
||
| 93 | return new class implements HydratorInterface |
||
| 94 | { |
||
| 95 | public function hydrate(array $data, InputType $type) |
||
| 96 | { |
||
| 97 | return new Contact($data['name']); |
||
| 98 | } |
||
| 141 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.