Conditions | 7 |
Paths | 1 |
Total Lines | 114 |
Code Lines | 11 |
Lines | 0 |
Ratio | 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 |
||
142 | public function admin_head() { |
||
143 | // remove the menu page so it is not visible in the admin side bar |
||
144 | remove_submenu_page( 'index.php', 'sensei-welcome' ); |
||
145 | ?> |
||
146 | <style type="text/css"> |
||
147 | /*<![CDATA[*/ |
||
148 | .sensei-badge:before { |
||
149 | font-family: dashicons !important; |
||
150 | content: "\f118"; |
||
151 | color: #fff; |
||
152 | -webkit-font-smoothing: antialiased; |
||
153 | -moz-osx-font-smoothing: grayscale; |
||
154 | font-size: 80px; |
||
155 | font-weight: normal; |
||
156 | width: 165px; |
||
157 | height: 165px; |
||
158 | line-height: 165px; |
||
159 | text-align: center; |
||
160 | position: absolute; |
||
161 | top: 0; |
||
162 | <?php echo is_rtl() ? 'right' : 'left'; ?>: 0; |
||
163 | margin: 0; |
||
164 | vertical-align: middle; |
||
165 | } |
||
166 | .sensei-badge { |
||
167 | position: relative; |
||
168 | background: #71b02f; |
||
169 | text-rendering: optimizeLegibility; |
||
170 | padding-top: 150px; |
||
171 | height: 52px; |
||
172 | width: 165px; |
||
173 | font-weight: 600; |
||
174 | font-size: 14px; |
||
175 | text-align: center; |
||
176 | color: rgba(255,255,255,0.8); |
||
177 | text-shadow: 0.05em 0.05em 1px rgba(0,0,0,0.1); |
||
178 | margin: 5px 0 0 0; |
||
179 | -webkit-box-shadow: 0 1px 3px rgba(0,0,0,.2); |
||
180 | box-shadow: 0 1px 3px rgba(0,0,0,.2); |
||
181 | } |
||
182 | .about-wrap .sensei-badge { |
||
183 | position: absolute; |
||
184 | top: 0; |
||
185 | <?php echo is_rtl() ? 'left' : 'right'; ?>: 0; |
||
186 | } |
||
187 | .about-wrap .sensei-feature { |
||
188 | overflow: visible !important; |
||
189 | *zoom:1; |
||
190 | } |
||
191 | .about-wrap h3 + .sensei-feature { |
||
192 | margin-top: 0; |
||
193 | } |
||
194 | .about-wrap .sensei-feature:before, |
||
195 | .about-wrap .sensei-feature:after { |
||
196 | content: " "; |
||
197 | display: table; |
||
198 | } |
||
199 | .about-wrap .sensei-feature:after { |
||
200 | clear: both; |
||
201 | } |
||
202 | .about-wrap .feature-rest div { |
||
203 | width: 50% !important; |
||
204 | padding-<?php echo is_rtl() ? 'left' : 'right'; ?>: 100px; |
||
205 | -moz-box-sizing: border-box; |
||
206 | box-sizing: border-box; |
||
207 | margin: 0 !important; |
||
208 | } |
||
209 | .about-wrap .feature-rest div.last-feature { |
||
210 | padding-<?php echo is_rtl() ? 'right' : 'left'; ?>: 100px; |
||
211 | padding-<?php echo is_rtl() ? 'left' : 'right'; ?>: 0; |
||
212 | } |
||
213 | .about-wrap div.icon { |
||
214 | width: 0 !important; |
||
215 | padding: 0; |
||
216 | margin: 20px 0 !important; |
||
217 | } |
||
218 | .about-wrap .feature-rest div.icon:before { |
||
219 | font-weight: normal; |
||
220 | width: 100%; |
||
221 | font-size: 170px; |
||
222 | line-height: 125px; |
||
223 | color: #9c5d90; |
||
224 | display: inline-block; |
||
225 | position: relative; |
||
226 | text-align: center; |
||
227 | speak: none; |
||
228 | margin: <?php echo is_rtl() ? '0 -100px 0 0' : '0 0 0 -100px'; ?>; |
||
229 | content: "\e01d"; |
||
230 | -webkit-font-smoothing: antialiased; |
||
231 | -moz-osx-font-smoothing: grayscale; |
||
232 | } |
||
233 | .about-integrations { |
||
234 | background: #fff; |
||
235 | margin: 20px 0; |
||
236 | padding: 1px 20px 10px; |
||
237 | } |
||
238 | .changelog h4 { |
||
239 | line-height: 1.4; |
||
240 | } |
||
241 | |||
242 | p.sensei-actions a.button-primary { |
||
243 | background: #42A2CE; |
||
244 | border-color: #849DAD; |
||
245 | } |
||
246 | |||
247 | p.sensei-actions .twitter-share-button { |
||
248 | margin-top: -3px; |
||
249 | margin-left: 3px; |
||
250 | vertical-align: middle; |
||
251 | } |
||
252 | /*]]>*/ |
||
253 | </style> |
||
254 | <?php |
||
255 | } |
||
256 | |||
308 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.