| Conditions | 1 |
| Paths | 1 |
| Total Lines | 100 |
| 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 |
||
| 9 | public function __invoke() |
||
| 10 | { |
||
| 11 | return [ |
||
| 12 | 'templates' => [ |
||
| 13 | 'paths' => [ |
||
| 14 | 'article' => [__DIR__.'/../templates/article'], |
||
| 15 | ], |
||
| 16 | ], |
||
| 17 | |||
| 18 | 'dependencies' => [ |
||
| 19 | 'factories' => [ |
||
| 20 | // Controllers |
||
| 21 | Controller\PostController::class => Factory\Controller\PostFactory::class, |
||
| 22 | Controller\DiscussionController::class => Factory\Controller\DiscussionFactory::class, |
||
| 23 | Controller\EventController::class => Factory\Controller\EventFactory::class, |
||
| 24 | Controller\VideoController::class => Factory\Controller\VideoFactory::class, |
||
| 25 | |||
| 26 | // Services |
||
| 27 | Service\PostService::class => Factory\Service\PostServiceFactory::class, |
||
| 28 | Service\DiscussionService::class => Factory\Service\DiscussionServiceFactory::class, |
||
| 29 | Service\EventService::class => Factory\Service\EventServiceFactory::class, |
||
| 30 | Service\VideoService::class => Factory\Service\VideoServiceFactory::class, |
||
| 31 | |||
| 32 | // Mappers |
||
| 33 | Mapper\ArticleMapper::class => \Std\MapperFactory::class, |
||
| 34 | Mapper\ArticlePostsMapper::class => \Std\MapperFactory::class, |
||
| 35 | Mapper\ArticleDiscussionsMapper::class => \Std\MapperFactory::class, |
||
| 36 | Mapper\ArticleEventsMapper::class => \Std\MapperFactory::class, |
||
| 37 | Mapper\ArticleVideosMapper::class => \Std\MapperFactory::class, |
||
| 38 | |||
| 39 | // Filters |
||
| 40 | Filter\ArticleFilter::class => InvokableFactory::class, |
||
| 41 | Filter\PostFilter::class => InvokableFactory::class, |
||
| 42 | Filter\DiscussionFilter::class => InvokableFactory::class, |
||
| 43 | Filter\EventFilter::class => InvokableFactory::class, |
||
| 44 | Filter\VideoFilter::class => InvokableFactory::class, |
||
| 45 | ], |
||
| 46 | ], |
||
| 47 | |||
| 48 | 'routes' => [ |
||
| 49 | [ |
||
| 50 | 'name' => 'admin.posts', |
||
| 51 | 'path' => '/admin/posts', |
||
| 52 | 'middleware' => Controller\PostController::class, |
||
| 53 | 'allowed_methods' => ['GET'], |
||
| 54 | ], |
||
| 55 | [ |
||
| 56 | 'name' => 'admin.posts.action', |
||
| 57 | 'path' => '/admin/posts/{action}/{id}', |
||
| 58 | 'middleware' => Controller\PostController::class, |
||
| 59 | 'allowed_methods' => ['GET', 'POST'], |
||
| 60 | ], |
||
| 61 | [ |
||
| 62 | 'name' => 'admin.discussions', |
||
| 63 | 'path' => '/admin/discussions', |
||
| 64 | 'middleware' => Controller\DiscussionController::class, |
||
| 65 | 'allowed_methods' => ['GET', 'POST'], |
||
| 66 | ], |
||
| 67 | [ |
||
| 68 | 'name' => 'admin.discussions.action', |
||
| 69 | 'path' => '/admin/discussions/{action}/{id}', |
||
| 70 | 'middleware' => Controller\DiscussionController::class, |
||
| 71 | 'allowed_methods' => ['GET', 'POST'], |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | 'name' => 'admin.events', |
||
| 75 | 'path' => '/admin/events', |
||
| 76 | 'middleware' => Controller\EventController::class, |
||
| 77 | 'allowed_methods' => ['GET', 'POST'], |
||
| 78 | ], |
||
| 79 | [ |
||
| 80 | 'name' => 'admin.events.action', |
||
| 81 | 'path' => '/admin/events/{action}/{id}', |
||
| 82 | 'middleware' => Controller\EventController::class, |
||
| 83 | 'allowed_methods' => ['GET', 'POST'], |
||
| 84 | ], |
||
| 85 | [ |
||
| 86 | 'name' => 'admin.videos', |
||
| 87 | 'path' => '/admin/videos', |
||
| 88 | 'middleware' => Controller\VideoController::class, |
||
| 89 | 'allowed_methods' => ['GET', 'POST'], |
||
| 90 | ], |
||
| 91 | [ |
||
| 92 | 'name' => 'admin.videos.action', |
||
| 93 | 'path' => '/admin/videos/{action}/{id}', |
||
| 94 | 'middleware' => Controller\VideoController::class, |
||
| 95 | 'allowed_methods' => ['GET', 'POST'], |
||
| 96 | ], |
||
| 97 | ], |
||
| 98 | |||
| 99 | 'view_helpers' => [ |
||
| 100 | 'factories' => [ |
||
| 101 | 'post' => Factory\View\Helper\PostHelperFactory::class, |
||
| 102 | 'event' => Factory\View\Helper\EventHelperFactory::class, |
||
| 103 | 'video' => Factory\View\Helper\VideoHelperFactory::class, |
||
| 104 | ], |
||
| 105 | ], |
||
| 106 | |||
| 107 | ]; |
||
| 108 | } |
||
| 109 | } |
||
| 110 |