| Conditions | 8 |
| Paths | 9 |
| Total Lines | 62 |
| Code Lines | 38 |
| 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 |
||
| 35 | #[Override] |
||
| 36 | public function handle(GameControllerInterface $game): void |
||
| 37 | { |
||
| 38 | $game->setView(ShowShip::VIEW_IDENTIFIER); |
||
| 39 | |||
| 40 | $userId = $game->getUser()->getId(); |
||
| 41 | $shipId = request::indInt('id'); |
||
| 42 | |||
| 43 | $wrapper = $this->shipLoader->getWrapperByIdAndUser( |
||
| 44 | $shipId, |
||
| 45 | $userId |
||
| 46 | ); |
||
| 47 | |||
| 48 | $ship = $wrapper->get(); |
||
| 49 | $bussardcollector = $wrapper->getBussardCollectorSystemData(); |
||
| 50 | |||
| 51 | if ($bussardcollector === null) { |
||
| 52 | throw new SanityCheckException('collector = null ', self::ACTION_IDENTIFIER); |
||
| 53 | } |
||
| 54 | |||
| 55 | if ($ship->isWarped()) { |
||
| 56 | $game->addInformation("Aktion nicht möglich, Schiff befindet sich im Warp"); |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | |||
| 60 | $chosenLocationId = request::postInt('chosen'); |
||
| 61 | |||
| 62 | if ($chosenLocationId === 0) { |
||
| 63 | if ($ship->isSystemHealthy(ShipSystemTypeEnum::SYSTEM_BUSSARD_COLLECTOR)) { |
||
| 64 | $this->helper->deactivate($wrapper, ShipSystemTypeEnum::SYSTEM_BUSSARD_COLLECTOR, $game); |
||
| 65 | } |
||
| 66 | |||
| 67 | $miningQueue = $this->miningQueueRepository->getByShip($ship->getId()); |
||
| 68 | if ($miningQueue !== null) { |
||
| 69 | $this->miningQueueRepository->truncateByShipId($ship->getId()); |
||
| 70 | $game->addInformation("Es werden keine Ressourcen mehr gesammelt"); |
||
| 71 | } |
||
| 72 | $this->shipStateChanger->changeShipState($wrapper, ShipStateEnum::SHIP_STATE_NONE); |
||
| 73 | return; |
||
| 74 | } else { |
||
| 75 | |||
| 76 | $locationMining = $this->locationMiningRepository->findById($chosenLocationId); |
||
| 77 | if ($locationMining === null) { |
||
| 78 | throw new SanityCheckException('Invalid location mining ID', self::ACTION_IDENTIFIER); |
||
| 79 | } |
||
| 80 | |||
| 81 | |||
| 82 | if (!$this->helper->activate($wrapper, ShipSystemTypeEnum::SYSTEM_BUSSARD_COLLECTOR, $game)) { |
||
| 83 | return; |
||
| 84 | } |
||
| 85 | $this->shipStateChanger->changeShipState($wrapper, ShipStateEnum::SHIP_STATE_GATHER_RESOURCES); |
||
| 86 | |||
| 87 | |||
| 88 | $miningqueue = $this->miningQueueRepository->prototype(); |
||
| 89 | $miningqueue->setShip($ship); |
||
| 90 | $miningqueue->setLocationMining($locationMining); |
||
| 91 | $this->miningQueueRepository->save($miningqueue); |
||
| 92 | |||
| 93 | $this->entityManager->flush(); |
||
| 94 | |||
| 95 | $game->addInformationf( |
||
| 96 | "Ressourcen werden gesammelt", |
||
| 97 | ); |
||
| 107 |
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