| Conditions | 19 |
| Paths | 49 |
| Total Lines | 68 |
| Lines | 68 |
| Ratio | 100 % |
| 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 |
||
| 53 | View Code Duplication | public function checkMissionCondition($game, $winner, $prediction, $entry) |
|
| 54 | { |
||
| 55 | $missionGame = $this->findMissionGameByGame($game); |
||
| 56 | if (empty($missionGame)) { |
||
| 57 | return false; |
||
| 58 | } |
||
| 59 | |||
| 60 | if ($missionGame->getMission()->getActive() === false) { |
||
| 61 | return false; |
||
| 62 | } |
||
| 63 | |||
| 64 | $nextMissionGame = $this->getMissionGameMapper()->getNextGame( |
||
| 65 | $missionGame->getMission(), |
||
| 66 | $missionGame->getPosition() |
||
| 67 | ); |
||
| 68 | |||
| 69 | if (empty($nextMissionGame)) { |
||
| 70 | return false; |
||
| 71 | } |
||
| 72 | |||
| 73 | $missionGameConditions = $this->findMissionGameConditionByMissionGame($nextMissionGame); |
||
| 74 | |||
| 75 | if (empty($missionGameConditions)) { |
||
| 76 | return false; |
||
| 77 | } |
||
| 78 | |||
| 79 | foreach ($missionGameConditions as $missionGameCondition) { |
||
| 80 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::NONE) { |
||
| 81 | continue; |
||
| 82 | } |
||
| 83 | |||
| 84 | // On passe au suivant si on a gagné |
||
| 85 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::VICTORY) { |
||
| 86 | if (!($winner || $prediction)) { |
||
| 87 | return false; |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | // On passe au suivant si on a perdu |
||
| 92 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::DEFEAT) { |
||
| 93 | if ($winner || $prediction) { |
||
| 94 | return false; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | // On passe au suivant si on a perdu |
||
| 99 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::GREATER) { |
||
| 100 | if (!$entry) { |
||
| 101 | return false; |
||
| 102 | } |
||
| 103 | if (!($entry->getPoints() > $missionGameCondition->getValue())) { |
||
| 104 | return false; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | // On passe au suivant si on a perdu |
||
| 109 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::LESS) { |
||
| 110 | if (!$entry) { |
||
| 111 | return false; |
||
| 112 | } |
||
| 113 | if (!($entry->getPoints() < $missionGameCondition->getValue())) { |
||
| 114 | return false; |
||
| 115 | } |
||
| 116 | } |
||
| 117 | } |
||
| 118 | |||
| 119 | return $nextMissionGame->getGame(); |
||
| 120 | } |
||
| 121 | |||
| 181 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.