| Conditions | 5 |
| Paths | 12 |
| Total Lines | 56 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 87 | public function pdf($file_name) |
||
| 88 | { |
||
| 89 | $csv = array_map('str_getcsv', file($file_name)); |
||
| 90 | |||
| 91 | $thead = array_shift($csv); |
||
| 92 | |||
| 93 | $lastKey = array_search(end($thead), $thead); |
||
| 94 | |||
| 95 | $html = ' |
||
| 96 | <html> |
||
| 97 | </head> |
||
| 98 | <style> |
||
| 99 | td, th { |
||
| 100 | border: 1px solid #dddddd; |
||
| 101 | text-align: left; |
||
| 102 | padding: 8px; |
||
| 103 | } |
||
| 104 | |||
| 105 | th { |
||
| 106 | |||
| 107 | font-family : bold; |
||
| 108 | |||
| 109 | } |
||
| 110 | |||
| 111 | </style> |
||
| 112 | </head> |
||
| 113 | '; |
||
| 114 | |||
| 115 | $html .= '<body><table><thead><tr>'; |
||
| 116 | |||
| 117 | for ($i = 0; $i < count($thead); $i++) { |
||
| 118 | $html .= "<th bgcolor='#ccc'>$thead[$i]</th>"; |
||
| 119 | } |
||
| 120 | |||
| 121 | if ($i >= count($thead)) { |
||
| 122 | $html .= '</tr></thead>'; |
||
| 123 | } |
||
| 124 | |||
| 125 | foreach ($csv as $tbody) { |
||
| 126 | $html .= '<tr>'; |
||
| 127 | foreach ($tbody as $td) { |
||
| 128 | $html .= "<td>$td</td>"; |
||
| 129 | } |
||
| 130 | $html .= '</tr>'; |
||
| 131 | } |
||
| 132 | |||
| 133 | $html .= '</table></body>'; |
||
| 134 | |||
| 135 | $id = DB::table('job_update')->insertGetId([ |
||
| 136 | 'name' => 'PDF', |
||
| 137 | 'status' => 'processing', |
||
| 138 | 'file_name' => '0', |
||
| 139 | ]); |
||
| 140 | WritePdf::dispatch($html, $id); |
||
| 141 | |||
| 142 | return response()->json(['message'=>'Preparing File For Download...'], 200); |
||
| 143 | } |
||
| 145 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths