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