Conditions | 3 |
Paths | 1 |
Total Lines | 65 |
Code Lines | 40 |
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 |
||
37 | public function toArray() |
||
38 | { |
||
39 | return array_replace_recursive( |
||
40 | [ |
||
41 | 'di' => [ |
||
42 | 'instance' => [ |
||
43 | 'alias' => [ |
||
44 | 'dbProfiler' => Profiler::class, |
||
45 | ], |
||
46 | Profiler::class => [ |
||
47 | 'parameters' => [ |
||
48 | 'enabled' => 'true', |
||
49 | ], |
||
50 | ], |
||
51 | DbCollector::class => [ |
||
52 | 'parameters' => [ |
||
53 | 'profiler' => 'dbProfiler', |
||
54 | ], |
||
55 | ], |
||
56 | ], |
||
57 | ], |
||
58 | 'service_manager' => [ |
||
59 | 'factories' => [ |
||
60 | 'defaultDb' => function ($services) { |
||
61 | $config = $services->get('Config')['db']; |
||
62 | if (empty($config)) { |
||
63 | return null; |
||
64 | } |
||
65 | |||
66 | $profiler = $services->get('dbProfiler'); |
||
67 | if (class_exists(ProfilingAdapter::class)) { |
||
68 | $adapter = new ProfilingAdapter($config); |
||
69 | $adapter->setProfiler($profiler); |
||
70 | $adapter->injectProfilingStatementPrototype(); |
||
71 | } else { |
||
72 | $adapter = new Adapter($config); |
||
73 | } |
||
74 | return $adapter; |
||
75 | }, |
||
76 | ], |
||
77 | ], |
||
78 | 'view_manager' => [ |
||
79 | 'display_not_found_reason' => true, |
||
80 | 'display_exceptions' => true, |
||
81 | ], |
||
82 | 'asset_manager' => [ |
||
83 | 'caching' => [ |
||
84 | 'default' => [ |
||
85 | 'cache' => 'FilePath', |
||
86 | 'options' => [ |
||
87 | 'dir' => $this->dir . '/../../public', |
||
88 | ], |
||
89 | ], |
||
90 | 'favicon.ico' => [ |
||
91 | 'cache' => 'Filesystem', |
||
92 | 'options' => [ |
||
93 | 'dir' => 'tmp/cache/common/assets', |
||
94 | ], |
||
95 | ], |
||
96 | ], |
||
97 | ], |
||
98 | ], |
||
99 | $this->override |
||
100 | ); |
||
101 | } |
||
102 | } |
||
103 |