Conditions | 1 |
Paths | 1 |
Total Lines | 80 |
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 | 'map' => [ |
||
14 | 'layout/admin' => __DIR__.'/../templates/layout/admin.phtml', |
||
15 | 'admin/pagination' => __DIR__.'/../templates/admin/partial/pagination.phtml', |
||
16 | ], |
||
17 | 'paths' => [ |
||
18 | 'admin' => [__DIR__.'/../templates/admin'], |
||
19 | ], |
||
20 | ], |
||
21 | |||
22 | 'dependencies' => [ |
||
23 | 'factories' => [ |
||
24 | 'session' => Factory\SessionFactory::class, |
||
25 | Action\IndexAction::class => Factory\Action\IndexFactory::class, |
||
26 | Action\ImageUploadAction::class => Factory\Action\ImageUploadFactory::class, |
||
27 | Controller\AuthController::class => Factory\Controller\AuthFactory::class, |
||
28 | Controller\UserController::class => Factory\Controller\UserFactory::class, |
||
29 | |||
30 | // Admin part |
||
31 | Service\AdminUserService::class => Factory\Service\AdminUserServiceFactory::class, |
||
32 | Mapper\AdminUsersMapper::class => \Std\MapperFactory::class, |
||
33 | Filter\AdminUserFilter::class => Factory\FilterFactory::class, |
||
34 | Middleware\AdminAuth::class => Factory\Middleware\AdminAuthFactory::class, |
||
35 | ], |
||
36 | ], |
||
37 | |||
38 | 'routes' => [ |
||
39 | [ |
||
40 | 'name' => 'auth', |
||
41 | 'path' => '/auth/{action}', |
||
42 | 'middleware' => Controller\AuthController::class, |
||
43 | 'allowed_methods' => ['GET', 'POST'], |
||
44 | ], |
||
45 | [ |
||
46 | 'name' => 'admin', |
||
47 | 'path' => '/admin', |
||
48 | 'middleware' => Action\IndexAction::class, |
||
49 | 'allowed_methods' => ['GET'], |
||
50 | ], |
||
51 | [ |
||
52 | 'name' => 'admin.users', |
||
53 | 'path' => '/admin/users', |
||
54 | 'middleware' => Controller\UserController::class, |
||
55 | 'allowed_methods' => ['GET'], |
||
56 | ], |
||
57 | [ |
||
58 | 'name' => 'admin.users.action', |
||
59 | 'path' => '/admin/users/{action}/{id}', |
||
60 | 'middleware' => Controller\UserController::class, |
||
61 | 'allowed_methods' => ['GET', 'POST'], |
||
62 | ], |
||
63 | [ |
||
64 | 'name' => 'admin.images.upload', |
||
65 | 'path' => '/admin/images/upload', |
||
66 | 'middleware' => Action\ImageUploadAction::class, |
||
67 | 'allowed_methods' => ['GET', 'POST'], |
||
68 | ], |
||
69 | ], |
||
70 | |||
71 | 'view_helpers' => [ |
||
72 | 'factories' => [ |
||
73 | 'admin' => Factory\View\Helper\AdminUserHelperFactory::class, |
||
74 | 'webAdmin' => Factory\View\Helper\WebAdminUserHelperFactory::class, |
||
75 | ], |
||
76 | ], |
||
77 | |||
78 | 'middleware_pipeline' => [ |
||
79 | // execute this middleware on every /admin[*] path |
||
80 | 'permission' => [ |
||
81 | 'middleware' => [Middleware\AdminAuth::class], |
||
82 | 'priority' => 100, |
||
83 | 'path' => '/admin', |
||
84 | ], |
||
85 | ], |
||
86 | |||
87 | ]; |
||
88 | } |
||
89 | } |
||
90 |