| Conditions | 10 | 
| Paths | 36 | 
| Total Lines | 56 | 
| 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 | ||
| 46 | public function executeQueryToTable($query) | ||
| 47 | 	{ | ||
| 48 | $out = ""; | ||
| 49 | |||
| 50 | $results = $this->executeQueryToArray($query); | ||
| 51 | |||
| 52 | $out .= '<table class="table table-striped table-hover table-condensed"><tr>'; | ||
| 53 | |||
| 54 | 		if ($this->numberedList == true) { | ||
|  | |||
| 55 | $out .= "<th>" . $this->numberedListTitle . "</th>"; | ||
| 56 | } | ||
| 57 | |||
| 58 | 		if ($this->overrideTableTitles != false) { | ||
| 59 | 			foreach ($this->overrideTableTitles as $value) { | ||
| 60 | $out .= "<th>" . $value . "</th>"; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | 		else { | ||
| 64 | 			if (count($results) > 0) { | ||
| 65 | 				foreach ($results[0] as $k => $v) { | ||
| 66 | $out .= "<th>" . $k . "</th>"; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | $out .= "</tr>"; | ||
| 71 | |||
| 72 | |||
| 73 | $currentreq = 0; | ||
| 74 | 		foreach ($results as $row) { | ||
| 75 | $currentreq++; | ||
| 76 | 			if (function_exists($this->tableCallbackFunction)) { | ||
| 77 | $out .= call_user_func($this->tableCallbackFunction, $row, $currentreq); | ||
| 78 | } | ||
| 79 | 			else { | ||
| 80 | $out .= '<tr>'; | ||
| 81 | |||
| 82 | 				if ($this->numberedList == true) { | ||
| 83 | $out .= "<th>" . $currentreq . "</th>"; | ||
| 84 | } | ||
| 85 | |||
| 86 | |||
| 87 | 				foreach ($row as $cell) { | ||
| 88 | |||
| 89 | $out .= "<td>" . $cell . "</td>"; | ||
| 90 | } | ||
| 91 | |||
| 92 | |||
| 93 | $out .= "</tr>"; | ||
| 94 | } | ||
| 95 | |||
| 96 | } | ||
| 97 | |||
| 98 | $out .= "</table>"; | ||
| 99 | |||
| 100 | return $out; | ||
| 101 | } | ||
| 102 | |||
| 115 | 
When comparing two booleans, it is generally considered safer to use the strict comparison operator.