| Conditions | 15 |
| Paths | 15 |
| Total Lines | 302 |
| Code Lines | 294 |
| 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 |
||
| 188 | public function sendNotif(Place $place, $case, Commander $commander, $report = NULL) { |
||
| 189 | switch ($case) { |
||
| 190 | case Place::CHANGESUCCESS: |
||
| 191 | $notif = new Notification(); |
||
| 192 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 193 | $notif->setTitle('Déplacement réussi'); |
||
| 194 | $notif->addBeg() |
||
| 195 | ->addTxt('Votre officier ') |
||
| 196 | ->addLnk('fleet/commander-' . $commander->getId(), $commander->getName()) |
||
| 197 | ->addTxt(' est arrivé sur ') |
||
| 198 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 199 | ->addTxt('.') |
||
| 200 | ->addEnd(); |
||
| 201 | $this->notificationManager->add($notif); |
||
| 202 | break; |
||
| 203 | |||
| 204 | case Place::CHANGEFAIL: |
||
| 205 | $notif = new Notification(); |
||
| 206 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 207 | $notif->setTitle('Déplacement réussi'); |
||
| 208 | $notif->addBeg() |
||
| 209 | ->addTxt('Votre officier ') |
||
| 210 | ->addLnk('fleet/commander-' . $commander->getId(), $commander->getName()) |
||
| 211 | ->addTxt(' s\'est posé sur ') |
||
| 212 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 213 | ->addTxt('. Il est en garnison car il n\'y avait pas assez de place en orbite.') |
||
| 214 | ->addEnd(); |
||
| 215 | $this->notificationManager->add($notif); |
||
| 216 | break; |
||
| 217 | case Place::CHANGELOST: |
||
| 218 | $notif = new Notification(); |
||
| 219 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 220 | $notif->setTitle('Déplacement raté'); |
||
| 221 | $notif->addBeg() |
||
| 222 | ->addTxt('Votre officier ') |
||
| 223 | ->addLnk('fleet/commander-' . $commander->getId(), $commander->getName()) |
||
| 224 | ->addTxt(' n\'est pas arrivé sur ') |
||
| 225 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 226 | ->addTxt('. Cette base ne vous appartient pas. Elle a pu être conquise entre temps.') |
||
| 227 | ->addEnd(); |
||
| 228 | $this->notificationManager->add($notif); |
||
| 229 | break; |
||
| 230 | case Place::LOOTEMPTYSSUCCESS: |
||
| 231 | $notif = new Notification(); |
||
| 232 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 233 | $notif->setTitle('Pillage réussi'); |
||
| 234 | $notif->addBeg() |
||
| 235 | ->addTxt('Votre officier ') |
||
| 236 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 237 | ->addTxt(' a pillé la planète rebelle située aux coordonnées ') |
||
| 238 | ->addLnk('map/place-' . $place->id, Game::formatCoord($place->xSystem, $place->ySystem, $place->position, $place->rSector)) |
||
| 239 | ->addTxt('.') |
||
| 240 | ->addSep() |
||
| 241 | ->addBoxResource('resource', Format::number($commander->getResources()), 'ressources pillées') |
||
| 242 | ->addBoxResource('xp', '+ ' . Format::number($commander->earnedExperience), 'expérience de l\'officier') |
||
| 243 | ->addSep() |
||
| 244 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 245 | ->addEnd(); |
||
| 246 | $this->notificationManager->add($notif); |
||
| 247 | break; |
||
| 248 | case Place::LOOTEMPTYFAIL: |
||
| 249 | $notif = new Notification(); |
||
| 250 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 251 | $notif->setTitle('Pillage raté'); |
||
| 252 | $notif->addBeg() |
||
| 253 | ->addTxt('Votre officier ') |
||
| 254 | ->addLnk('fleet/view-memorial', $commander->getName()) |
||
| 255 | ->addTxt(' est tombé lors de l\'attaque de la planète rebelle située aux coordonnées ') |
||
| 256 | ->addLnk('map/place-' . $place->id, Game::formatCoord($place->xSystem, $place->ySystem, $place->position, $place->rSector)) |
||
| 257 | ->addTxt('.') |
||
| 258 | ->addSep() |
||
| 259 | ->addTxt('Il a désormais rejoint le Mémorial. Que son âme traverse l\'Univers dans la paix.') |
||
| 260 | ->addSep() |
||
| 261 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 262 | ->addEnd(); |
||
| 263 | $this->notificationManager->add($notif); |
||
| 264 | break; |
||
| 265 | case Place::LOOTPLAYERWHITBATTLESUCCESS: |
||
| 266 | $notif = new Notification(); |
||
| 267 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 268 | $notif->setTitle('Pillage réussi'); |
||
| 269 | $notif->addBeg() |
||
| 270 | ->addTxt('Votre officier ') |
||
| 271 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 272 | ->addTxt(' a pillé la planète ') |
||
| 273 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 274 | ->addTxt(' appartenant au joueur ') |
||
| 275 | ->addLnk('embassy/player-' . $place->rPlayer, $place->playerName) |
||
| 276 | ->addTxt('.') |
||
| 277 | ->addSep() |
||
| 278 | ->addBoxResource('resource', Format::number($commander->getResources()), 'ressources pillées') |
||
| 279 | ->addBoxResource('xp', '+ ' . Format::number($commander->earnedExperience), 'expérience de l\'officier') |
||
| 280 | ->addSep() |
||
| 281 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 282 | ->addEnd(); |
||
| 283 | $this->notificationManager->add($notif); |
||
| 284 | |||
| 285 | $notif = new Notification(); |
||
| 286 | $notif->setRPlayer($place->rPlayer); |
||
| 287 | $notif->setTitle('Rapport de pillage'); |
||
| 288 | $notif->addBeg() |
||
| 289 | ->addTxt('L\'officier ') |
||
| 290 | ->addStg($commander->getName()) |
||
| 291 | ->addTxt(' appartenant au joueur ') |
||
| 292 | ->addLnk('embassy/player-' . $commander->getRPlayer(), $commander->getPlayerName()) |
||
| 293 | ->addTxt(' a pillé votre planète ') |
||
| 294 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 295 | ->addTxt('.') |
||
| 296 | ->addSep() |
||
| 297 | ->addBoxResource('resource', Format::number($commander->getResources()), 'ressources pillées') |
||
| 298 | ->addSep() |
||
| 299 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 300 | ->addEnd(); |
||
| 301 | $this->notificationManager->add($notif); |
||
| 302 | break; |
||
| 303 | case Place::LOOTPLAYERWHITBATTLEFAIL: |
||
| 304 | $notif = new Notification(); |
||
| 305 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 306 | $notif->setTitle('Pillage raté'); |
||
| 307 | $notif->addBeg() |
||
| 308 | ->addTxt('Votre officier ') |
||
| 309 | ->addLnk('fleet/view-memorial', $commander->getName()) |
||
| 310 | ->addTxt(' est tombé lors du pillage de la planète ') |
||
| 311 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 312 | ->addTxt(' appartenant au joueur ') |
||
| 313 | ->addLnk('embassy/player-' . $place->rPlayer, $place->playerName) |
||
| 314 | ->addTxt('.') |
||
| 315 | ->addSep() |
||
| 316 | ->addTxt('Il a désormais rejoint le Mémorial. Que son âme traverse l\'Univers dans la paix.') |
||
| 317 | ->addSep() |
||
| 318 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 319 | ->addEnd(); |
||
| 320 | $this->notificationManager->add($notif); |
||
| 321 | |||
| 322 | $notif = new Notification(); |
||
| 323 | $notif->setRPlayer($place->rPlayer); |
||
| 324 | $notif->setTitle('Rapport de combat'); |
||
| 325 | $notif->addBeg() |
||
| 326 | ->addTxt('L\'officier ') |
||
| 327 | ->addStg($commander->getName()) |
||
| 328 | ->addTxt(' appartenant au joueur ') |
||
| 329 | ->addLnk('embassy/player-' . $commander->getRPlayer(), $commander->getPlayerName()) |
||
| 330 | ->addTxt(' a attaqué votre planète ') |
||
| 331 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 332 | ->addTxt('.') |
||
| 333 | ->addSep() |
||
| 334 | ->addTxt('Vous avez repoussé l\'ennemi avec succès.') |
||
| 335 | ->addSep() |
||
| 336 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 337 | ->addEnd(); |
||
| 338 | $this->notificationManager->add($notif); |
||
| 339 | break; |
||
| 340 | case Place::LOOTPLAYERWHITOUTBATTLESUCCESS: |
||
| 341 | $notif = new Notification(); |
||
| 342 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 343 | $notif->setTitle('Pillage réussi'); |
||
| 344 | $notif->addBeg() |
||
| 345 | ->addTxt('Votre officier ') |
||
| 346 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 347 | ->addTxt(' a pillé la planète non défendue ') |
||
| 348 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 349 | ->addTxt(' appartenant au joueur ') |
||
| 350 | ->addLnk('embassy/player-' . $place->rPlayer, $place->playerName) |
||
| 351 | ->addTxt('.') |
||
| 352 | ->addSep() |
||
| 353 | ->addBoxResource('resource', Format::number($commander->getResources()), 'ressources pillées') |
||
| 354 | ->addBoxResource('xp', '+ ' . Format::number($commander->earnedExperience), 'expérience de l\'officier') |
||
| 355 | ->addEnd(); |
||
| 356 | $this->notificationManager->add($notif); |
||
| 357 | |||
| 358 | $notif = new Notification(); |
||
| 359 | $notif->setRPlayer($place->rPlayer); |
||
| 360 | $notif->setTitle('Rapport de pillage'); |
||
| 361 | $notif->addBeg() |
||
| 362 | ->addTxt('L\'officier ') |
||
| 363 | ->addStg($commander->getName()) |
||
| 364 | ->addTxt(' appartenant au joueur ') |
||
| 365 | ->addLnk('embassy/player-' . $commander->getRPlayer(), $commander->getPlayerName()) |
||
| 366 | ->addTxt(' a pillé votre planète ') |
||
| 367 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 368 | ->addTxt('. Aucune flotte n\'était en position pour la défendre. ') |
||
| 369 | ->addSep() |
||
| 370 | ->addBoxResource('resource', Format::number($commander->getResources()), 'ressources pillées') |
||
| 371 | ->addEnd(); |
||
| 372 | $this->notificationManager->add($notif); |
||
| 373 | break; |
||
| 374 | case Place::LOOTLOST: |
||
| 375 | $notif = new Notification(); |
||
| 376 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 377 | $notif->setTitle('Erreur de coordonnées'); |
||
| 378 | $notif->addBeg() |
||
| 379 | ->addTxt('Votre officier ') |
||
| 380 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 381 | ->addTxt(' n\'a pas attaqué la planète ') |
||
| 382 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 383 | ->addTxt(' car son joueur est de votre faction, sous la protection débutant ou un allié.') |
||
| 384 | ->addEnd(); |
||
| 385 | $this->notificationManager->add($notif); |
||
| 386 | break; |
||
| 387 | case Place::CONQUEREMPTYSSUCCESS: |
||
| 388 | $notif = new Notification(); |
||
| 389 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 390 | $notif->setTitle('Colonisation réussie'); |
||
| 391 | $notif->addBeg() |
||
| 392 | ->addTxt('Votre officier ') |
||
| 393 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 394 | ->addTxt(' a colonisé la planète rebelle située aux coordonnées ') |
||
| 395 | ->addLnk('map/place-' . $place->id , Game::formatCoord($place->xSystem, $place->ySystem, $place->position, $place->rSector) . '.') |
||
| 396 | ->addBoxResource('xp', '+ ' . Format::number($commander->earnedExperience), 'expérience de l\'officier') |
||
| 397 | ->addTxt('Votre empire s\'étend, administrez votre ') |
||
| 398 | ->addLnk('bases/base-' . $place->id, 'nouvelle planète') |
||
| 399 | ->addTxt('.') |
||
| 400 | ->addSep() |
||
| 401 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 402 | ->addEnd(); |
||
| 403 | $this->notificationManager->add($notif); |
||
| 404 | break; |
||
| 405 | case Place::CONQUEREMPTYFAIL: |
||
| 406 | $notif = new Notification(); |
||
| 407 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 408 | $notif->setTitle('Colonisation ratée'); |
||
| 409 | $notif->addBeg() |
||
| 410 | ->addTxt('Votre officier ') |
||
| 411 | ->addLnk('fleet/view-memorial', $commander->getName()) |
||
| 412 | ->addTxt(' est tombé lors de l\'attaque de la planète rebelle située aux coordonnées ') |
||
| 413 | ->addLnk('map/place-' . $place->id, Game::formatCoord($place->xSystem, $place->ySystem, $place->position, $place->rSector)) |
||
| 414 | ->addTxt('.') |
||
| 415 | ->addSep() |
||
| 416 | ->addTxt('Il a désormais rejoint le Mémorial. Que son âme traverse l\'Univers dans la paix.') |
||
| 417 | ->addSep() |
||
| 418 | ->addLnk('fleet/view-archive/report-' . $report, 'voir le rapport') |
||
| 419 | ->addEnd(); |
||
| 420 | $this->notificationManager->add($notif); |
||
| 421 | break; |
||
| 422 | case Place::CONQUERPLAYERWHITOUTBATTLESUCCESS: |
||
| 423 | $notif = new Notification(); |
||
| 424 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 425 | $notif->setTitle('Conquête réussie'); |
||
| 426 | $notif->addBeg() |
||
| 427 | ->addTxt('Votre officier ') |
||
| 428 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 429 | ->addTxt(' a conquis la planète non défendue ') |
||
| 430 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 431 | ->addTxt(' appartenant au joueur ') |
||
| 432 | ->addLnk('embassy/player-' . $place->rPlayer, $place->playerName) |
||
| 433 | ->addTxt('.') |
||
| 434 | ->addSep() |
||
| 435 | ->addBoxResource('xp', '+ ' . Format::number($commander->earnedExperience), 'expérience de l\'officier') |
||
| 436 | ->addTxt('Elle est désormais votre, vous pouvez l\'administrer ') |
||
| 437 | ->addLnk('bases/base-' . $place->id, 'ici') |
||
| 438 | ->addTxt('.') |
||
| 439 | ->addEnd(); |
||
| 440 | $this->notificationManager->add($notif); |
||
| 441 | |||
| 442 | $notif = new Notification(); |
||
| 443 | $notif->setRPlayer($place->rPlayer); |
||
| 444 | $notif->setTitle('Planète conquise'); |
||
| 445 | $notif->addBeg() |
||
| 446 | ->addTxt('L\'officier ') |
||
| 447 | ->addStg($commander->getName()) |
||
| 448 | ->addTxt(' appartenant au joueur ') |
||
| 449 | ->addLnk('embassy/player-' . $commander->getRPlayer(), $commander->getPlayerName()) |
||
| 450 | ->addTxt(' a conquis votre planète non défendue ') |
||
| 451 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 452 | ->addTxt('.') |
||
| 453 | ->addSep() |
||
| 454 | ->addTxt('Impliquez votre faction dans une action punitive envers votre assaillant.') |
||
| 455 | ->addEnd(); |
||
| 456 | $this->notificationManager->add($notif); |
||
| 457 | break; |
||
| 458 | case Place::CONQUERLOST: |
||
| 459 | $notif = new Notification(); |
||
| 460 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 461 | $notif->setTitle('Erreur de coordonnées'); |
||
| 462 | $notif->addBeg() |
||
| 463 | ->addTxt('Votre officier ') |
||
| 464 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 465 | ->addTxt(' n\'a pas attaqué la planète ') |
||
| 466 | ->addLnk('map/place-' . $place->id, $place->baseName) |
||
| 467 | ->addTxt(' car le joueur est dans votre faction, sous la protection débutant ou votre allié.') |
||
| 468 | ->addEnd(); |
||
| 469 | $this->notificationManager->add($notif); |
||
| 470 | break; |
||
| 471 | case Place::COMEBACK: |
||
| 472 | $notif = new Notification(); |
||
| 473 | $notif->setRPlayer($commander->getRPlayer()); |
||
| 474 | $notif->setTitle('Rapport de retour'); |
||
| 475 | $notif->addBeg() |
||
| 476 | ->addTxt('Votre officier ') |
||
| 477 | ->addLnk('fleet/commander-' . $commander->getId() . '/sftr-3', $commander->getName()) |
||
| 478 | ->addTxt(' est de retour sur votre base ') |
||
| 479 | ->addLnk('map/place-' . $commander->getRBase(), $commander->getBaseName()) |
||
| 480 | ->addTxt(' et rapporte ') |
||
| 481 | ->addStg(Format::number($commander->getResources())) |
||
| 482 | ->addTxt(' ressources à vos entrepôts.') |
||
| 483 | ->addEnd(); |
||
| 484 | $this->notificationManager->add($notif); |
||
| 485 | break; |
||
| 486 | |||
| 487 | default: break; |
||
| 488 | } |
||
| 489 | } |
||
| 490 | |||
| 598 | } |