Conditions | 4 |
Paths | 8 |
Total Lines | 53 |
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 |
||
55 | public function getAppJs(View $View, ForumsUserInterface $CurrentUser) |
||
56 | { |
||
57 | $settings = Configure::read('Saito.Settings'); |
||
58 | $request = $View->getRequest(); |
||
59 | |||
60 | $js = $this->_JsData->getJs(); |
||
61 | $js += [ |
||
62 | 'app' => [ |
||
63 | 'version' => Configure::read('Saito.v'), |
||
64 | 'settings' => [ |
||
65 | 'autoPageReload' => (isset($View->viewVars['autoPageReload']) ? $View->viewVars['autoPageReload'] : 0), |
||
66 | 'editPeriod' => (int)Configure::read( |
||
67 | 'Saito.Settings.edit_period' |
||
68 | ), |
||
69 | 'language' => Configure::read('Saito.language'), |
||
70 | 'notificationIcon' => $this->Url->assetUrl( |
||
71 | 'html5-notification-icon.png', |
||
72 | [ |
||
73 | 'pathPrefix' => Configure::read('App.imageBaseUrl'), |
||
74 | 'fullBase' => true |
||
75 | ] |
||
76 | ), |
||
77 | 'quote_symbol' => $settings['quote_symbol'], |
||
78 | 'subject_maxlength' => $settings['subject_maxlength'], |
||
79 | 'theme' => $View->getTheme(), |
||
80 | 'apiroot' => $request->getAttribute('webroot') . 'api/v2/', |
||
81 | 'webroot' => $request->getAttribute('webroot') |
||
82 | ] |
||
83 | ], |
||
84 | 'request' => [ |
||
85 | 'action' => $request->getParam('action'), |
||
86 | 'controller' => $request->getParam('controller'), |
||
87 | 'isMobile' => $request->isMobile(), |
||
88 | 'isPreview' => $request->isPreview(), |
||
89 | 'csrf' => $this->_getCsrf($View) |
||
90 | ], |
||
91 | 'currentUser' => [ |
||
92 | 'id' => (int)$CurrentUser->get('id'), |
||
93 | 'username' => $CurrentUser->get('username'), |
||
94 | 'user_show_inline' => $CurrentUser->get('inline_view_on_click') || false, |
||
95 | 'user_show_thread_collapsed' => $CurrentUser->get('user_show_thread_collapsed') || false |
||
96 | ], |
||
97 | 'callbacks' => [ |
||
98 | 'beforeAppInit' => [], |
||
99 | 'afterAppInit' => [], |
||
100 | 'afterViewInit' => [] |
||
101 | ] |
||
102 | ]; |
||
103 | $out = 'var SaitoApp = ' . json_encode($js); |
||
104 | $out .= '; SaitoApp.timeAppStart = new Date().getTime();'; |
||
105 | |||
106 | return $out; |
||
107 | } |
||
108 | |||
144 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.