| Conditions | 5 |
| Paths | 12 |
| Total Lines | 61 |
| Code Lines | 20 |
| 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 |
||
| 103 | public function pdf($file_name) |
||
| 104 | { |
||
| 105 | |||
| 106 | $csv = array_map('str_getcsv',file($file_name)); |
||
| 107 | |||
| 108 | $thead = array_shift($csv); |
||
| 109 | |||
| 110 | $lastKey = array_search(end($thead), $thead); |
||
| 111 | |||
| 112 | |||
| 113 | |||
| 114 | $html = ' |
||
| 115 | <html> |
||
| 116 | </head> |
||
| 117 | <style> |
||
| 118 | td, th { |
||
| 119 | border: 1px solid #dddddd; |
||
| 120 | text-align: left; |
||
| 121 | padding: 8px; |
||
| 122 | } |
||
| 123 | |||
| 124 | th { |
||
| 125 | |||
| 126 | font-family : bold; |
||
| 127 | |||
| 128 | } |
||
| 129 | |||
| 130 | </style> |
||
| 131 | </head> |
||
| 132 | '; |
||
| 133 | |||
| 134 | $html .= '<body><table><thead><tr>'; |
||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | |||
| 139 | for($i = 0 ; $i<count($thead); $i++) { |
||
| 140 | $html.= "<th bgcolor='#ccc'>$thead[$i]</th>"; |
||
| 141 | } |
||
| 142 | |||
| 143 | |||
| 144 | if($i>=count($thead)) $html.= "</tr></thead>"; |
||
| 145 | |||
| 146 | foreach($csv as $tbody) { |
||
| 147 | $html .= "<tr>"; |
||
| 148 | foreach ($tbody as $td ) { |
||
| 149 | $html .= "<td>$td</td>"; |
||
| 150 | } |
||
| 151 | $html .= "</tr>"; |
||
| 152 | } |
||
| 153 | |||
| 154 | |||
| 155 | $html .= "</table></body>"; |
||
| 156 | |||
| 157 | $id = DB::table('job_update')->insertGetId([ |
||
| 158 | "name" => "PDF", |
||
| 159 | "status" => 'processing', |
||
| 160 | "file_name" => '0' |
||
| 161 | ]); |
||
| 162 | WritePdf::dispatch($html,$id); |
||
| 163 | return response()->json(["message"=>"Preparing File For Download..."], 200); |
||
| 164 | } |
||
| 166 | } |
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