Conditions | 13 |
Paths | 15 |
Total Lines | 46 |
Code Lines | 22 |
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 |
||
47 | public function postRequest(HTTPRequest $request, HTTPResponse $response) |
||
48 | { |
||
49 | $debugbar = DebugBar::getDebugBar(); |
||
50 | if (!$debugbar) { |
||
51 | return; |
||
52 | } |
||
53 | |||
54 | // All queries have been displayed |
||
55 | if (DebugBar::getShowQueries()) { |
||
56 | exit(); |
||
57 | } |
||
58 | |||
59 | $script = DebugBar::renderDebugBar(); |
||
60 | |||
61 | // If the bar is not renderable, return early |
||
62 | if (!$script) { |
||
63 | return; |
||
64 | } |
||
65 | |||
66 | // Inject init script into the HTML response |
||
67 | $body = $response->getBody(); |
||
68 | if (strpos($body, '</body>') !== false) { |
||
69 | $body = str_replace('</body>', $script . '</body>', $body); |
||
70 | $response->setBody($body); |
||
71 | } |
||
72 | |||
73 | // Ajax support |
||
74 | if (Director::is_ajax() && !headers_sent()) { |
||
75 | if (DebugBar::isAdminUrl() && !DebugBar::config()->enabled_in_admin) { |
||
76 | return; |
||
77 | } |
||
78 | // Skip anything that is not a GET request |
||
79 | if (!$request->isGET()) { |
||
80 | return; |
||
81 | } |
||
82 | // Always enable in admin because everything is mostly loaded through ajax |
||
83 | if (DebugBar::config()->ajax || DebugBar::isAdminUrl()) { |
||
84 | $headers = $debugbar->getDataAsHeaders(); |
||
85 | |||
86 | // Prevent throwing js errors in case header size is too large |
||
87 | if (is_array($headers)) { |
||
88 | $debugbar->sendDataInHeaders(); |
||
89 | } |
||
90 | } |
||
91 | } |
||
92 | } |
||
93 | } |
||
94 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.