| Conditions | 22 | 
| Paths | > 20000 | 
| Total Lines | 128 | 
| 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 | ||
| 204 | function printBbcKilometersByQuartil($kmByQuartil, $tauxRemb, $unitPriceMission) | ||
| 205 | { | ||
| 206 | print '<table class="border" width="100%">'; | ||
| 207 | |||
| 208 | print '<tr>'; | ||
| 209 | print '<td></td>'; | ||
| 210 | print '<td></td>'; | ||
| 211 | |||
| 212 | print '<td class="liste_titre" colspan="5">Trimestre 1 (Jan - Mars)</td>'; | ||
| 213 | print '<td class="liste_titre" colspan="5">Trimestre 2 (Avr - Juin)</td>'; | ||
| 214 | print '<td class="liste_titre" colspan="5">Trimestre 3 (Juil - Sept)</td>'; | ||
| 215 | print '<td class="liste_titre" colspan="5">Trimestre 4 (Oct - Dec)</td>'; | ||
| 216 | print '<td class="liste_titre" >Total</td>'; | ||
| 217 | |||
| 218 | print '</tr>'; | ||
| 219 | |||
| 220 | print '<tr class="liste_titre">'; | ||
| 221 | print '<td class="liste_titre" > Nom </td>'; | ||
| 222 | print '<td class="liste_titre" > Prenom </td>'; | ||
| 223 | |||
| 224 | |||
| 225 | print '<td class="liste_titre" > # T1 & T2</td>'; | ||
| 226 | print '<td class="liste_titre" > Forfaits pil </td>'; | ||
| 227 | print '<td class="liste_titre" > Total des KM </td>'; | ||
| 228 | print '<td class="liste_titre" > Remb km €</td>'; | ||
| 229 | print '<td class="liste_titre" > Total € </td>'; | ||
| 230 | |||
| 231 | print '<td class="liste_titre" > # T1 & T2</td>'; | ||
| 232 | print '<td class="liste_titre" > Forfaits pil </td>'; | ||
| 233 | print '<td class="liste_titre" > Total des KM </td>'; | ||
| 234 | print '<td class="liste_titre" > Remb km €</td>'; | ||
| 235 | print '<td class="liste_titre" > Total € </td>'; | ||
| 236 | |||
| 237 | print '<td class="liste_titre" > # T1 & T2</td>'; | ||
| 238 | print '<td class="liste_titre" > Forfaits pil </td>'; | ||
| 239 | print '<td class="liste_titre" > Total des KM </td>'; | ||
| 240 | print '<td class="liste_titre" > Remb km €</td>'; | ||
| 241 | print '<td class="liste_titre" > Total € </td>'; | ||
| 242 | |||
| 243 | print '<td class="liste_titre" > # T1 & T2</td>'; | ||
| 244 | print '<td class="liste_titre" > Forfaits pil </td>'; | ||
| 245 | print '<td class="liste_titre" > Total des KM </td>'; | ||
| 246 | print '<td class="liste_titre" > Remb km €</td>'; | ||
| 247 | print '<td class="liste_titre" > Total € </td>'; | ||
| 248 | |||
| 249 | print '<td class="liste_titre" > Total € </td>'; | ||
| 250 | print '</tr>'; | ||
| 251 | |||
| 252 | $totalQ1 = 0; | ||
| 253 | $totalQ2 = 0; | ||
| 254 | $totalQ3 = 0; | ||
| 255 | $totalQ4 = 0; | ||
| 256 | |||
| 257 |     $curMonth = date("m", time()); | ||
| 258 | $curQuarter = ceil($curMonth / 3); | ||
| 259 | $disableColor = 'style="background-color: lightyellow;" title="N/A" data-toggle="tooltip"'; | ||
| 260 | |||
| 261 | /** @var PilotMissions $pilotMission */ | ||
| 262 |     foreach ($kmByQuartil as $pilotMission) { | ||
| 263 | $sumQ1 = $pilotMission->getTotalOfKilometersForQuarter(1); | ||
| 264 | $sumQ2 = $pilotMission->getTotalOfKilometersForQuarter(2); | ||
| 265 | $sumQ3 = $pilotMission->getTotalOfKilometersForQuarter(3); | ||
| 266 | $sumQ4 = $pilotMission->getTotalOfKilometersForQuarter(4); | ||
| 267 | |||
| 268 | $flightsQ1 = $pilotMission->getNumberOfFlightsForQuarter(1); | ||
| 269 | $flightsQ2 = $pilotMission->getNumberOfFlightsForQuarter(2); | ||
| 270 | $flightsQ3 = $pilotMission->getNumberOfFlightsForQuarter(3); | ||
| 271 | $flightsQ4 = $pilotMission->getNumberOfFlightsForQuarter(4); | ||
| 272 | |||
| 273 | $amoutQ1 = ($sumQ1 * $tauxRemb) + ($flightsQ1 * $unitPriceMission); | ||
| 274 | $amoutQ2 = ($sumQ2 * $tauxRemb) + ($flightsQ2 * $unitPriceMission); | ||
| 275 | $amoutQ3 = ($sumQ3 * $tauxRemb) + ($flightsQ3 * $unitPriceMission); | ||
| 276 | $amoutQ4 = ($sumQ4 * $tauxRemb) + ($flightsQ4 * $unitPriceMission); | ||
| 277 | |||
| 278 | $totalQ1 += $amoutQ1; | ||
| 279 | $totalQ2 += $amoutQ2; | ||
| 280 | $totalQ3 += $amoutQ3; | ||
| 281 | $totalQ4 += $amoutQ4; | ||
| 282 | |||
| 283 | $sumKm = ($sumQ1 + $sumQ2 + $sumQ3 + $sumQ4); | ||
| 284 | $sumFlights = ($flightsQ1 + $flightsQ2 + $flightsQ3 + $flightsQ4); | ||
| 285 | |||
| 286 | print '<tr>'; | ||
| 287 | |||
| 288 | print '<td>' . $pilotMission->getPilotLastname() . '</td>'; | ||
| 289 | print '<td>' . $pilotMission->getPilotFirstname() . '</td>'; | ||
| 290 | |||
| 291 | print '<td' . ($curQuarter < 1 ? $disableColor : '') . '>' . ($flightsQ1) . '</td>'; | ||
| 292 | print '<td' . ($curQuarter < 1 ? $disableColor : '') . '>' . ($flightsQ1 * $unitPriceMission) . '€</td>'; | ||
| 293 | print '<td' . ($curQuarter < 1 ? $disableColor : '') . '>' . $sumQ1 . '</td>'; | ||
| 294 | print '<td' . ($curQuarter < 1 ? $disableColor : '') . '>' . ($sumQ1 * $tauxRemb) . '</td>'; | ||
| 295 | print '<td' . ($curQuarter < 1 ? $disableColor : '') . '><b>' . $amoutQ1 . '€</b></td>'; | ||
| 296 | |||
| 297 | print '<td ' . ($curQuarter < 2 ? $disableColor : '') . '>' . ($flightsQ2) . '</td>'; | ||
| 298 | print '<td ' . ($curQuarter < 2 ? $disableColor : '') . '>' . ($flightsQ2 * $unitPriceMission) . '€</td>'; | ||
| 299 | print '<td ' . ($curQuarter < 2 ? $disableColor : '') . '>' . $sumQ2 . '</td>'; | ||
| 300 | print '<td ' . ($curQuarter < 2 ? $disableColor : '') . '>' . ($sumQ2 * $tauxRemb) . '</td>'; | ||
| 301 | print '<td ' . ($curQuarter < 2 ? $disableColor : '') . '><b>' . $amoutQ2 . '€</b></td>'; | ||
| 302 | |||
| 303 | print '<td ' . ($curQuarter < 3 ? $disableColor : '') . '>' . ($flightsQ3) . '</td>'; | ||
| 304 | print '<td ' . ($curQuarter < 3 ? $disableColor : '') . '>' . ($flightsQ3 * $unitPriceMission) . '€</td>'; | ||
| 305 | print '<td ' . ($curQuarter < 3 ? $disableColor : '') . '>' . $sumQ3 . '</td>'; | ||
| 306 | print '<td ' . ($curQuarter < 3 ? $disableColor : '') . '>' . ($sumQ3 * $tauxRemb) . '</td>'; | ||
| 307 | print '<td ' . ($curQuarter < 3 ? $disableColor : '') . '><b>' . $amoutQ3 . '€</b></td>'; | ||
| 308 | |||
| 309 | print '<td ' . ($curQuarter < 4 ? $disableColor : '') . '>' . ($flightsQ4) . '</td>'; | ||
| 310 | print '<td ' . ($curQuarter < 4 ? $disableColor : '') . '>' . ($flightsQ4 * $unitPriceMission) . '€</td>'; | ||
| 311 | print '<td ' . ($curQuarter < 4 ? $disableColor : '') . '>' . $sumQ4 . '</td>'; | ||
| 312 | print '<td ' . ($curQuarter < 4 ? $disableColor : '') . '>' . ($sumQ4 * $tauxRemb) . '</td>'; | ||
| 313 | print '<td ' . ($curQuarter < 4 ? $disableColor : '') . '><b>' . $amoutQ4 . '€</b></td>'; | ||
| 314 | |||
| 315 | print '<td>' . (($sumFlights * $unitPriceMission) + ($sumKm * $tauxRemb)) . '€</td>'; | ||
| 316 | |||
| 317 | print '</tr>'; | ||
| 318 | } | ||
| 319 | |||
| 320 | print "<td colspan='6'></td>"; | ||
| 321 | print "<td>" . price($totalQ1) . "€</td>"; | ||
| 322 | print "<td colspan='4'></td>"; | ||
| 323 | print "<td>" . price($totalQ2) . "€</td>"; | ||
| 324 | print "<td colspan='4'></td>"; | ||
| 325 | print "<td>" . price($totalQ3) . "€</td>"; | ||
| 326 | print "<td colspan='4'></td>"; | ||
| 327 | print "<td>" . price($totalQ4) . "€</td>"; | ||
| 328 | print "<td></td>"; | ||
| 329 | |||
| 330 | print '</table>'; | ||
| 331 | } | ||
| 332 | |||
| 412 | } |