| Conditions | 19 |
| Paths | 49 |
| Total Lines | 69 |
| Code Lines | 34 |
| Lines | 66 |
| Ratio | 95.65 % |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 56 | View Code Duplication | public function checkMissionCondition($game, $winner, $prediction, $entry) |
|
| 57 | { |
||
| 58 | $missionGame = $this->findMissionGameByGame($game); |
||
| 59 | if (empty($missionGame)) { |
||
| 60 | return false; |
||
| 61 | } |
||
| 62 | |||
| 63 | if ($missionGame->getMission()->getActive() === false) { |
||
| 64 | return false; |
||
| 65 | } |
||
| 66 | |||
| 67 | $nextMissionGame = $this->getMissionGameMapper()->getNextGame( |
||
| 68 | $missionGame->getMission(), |
||
| 69 | $missionGame->getPosition() |
||
| 70 | ); |
||
| 71 | |||
| 72 | if (empty($nextMissionGame)) { |
||
| 73 | return false; |
||
| 74 | } |
||
| 75 | |||
| 76 | $missionGameConditions = $this->findMissionGameConditionByMissionGame($nextMissionGame); |
||
| 77 | |||
| 78 | if (empty($missionGameConditions)) { |
||
| 79 | return false; |
||
| 80 | } |
||
| 81 | |||
| 82 | foreach ($missionGameConditions as $missionGameCondition) { |
||
| 83 | |||
| 84 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::NONE) { |
||
| 85 | continue; |
||
| 86 | } |
||
| 87 | |||
| 88 | // On passe au suivant si on a gagné |
||
| 89 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::VICTORY) { |
||
| 90 | if (!($winner || $prediction)) { |
||
| 91 | return false; |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | // On passe au suivant si on a perdu |
||
| 96 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::DEFEAT) { |
||
| 97 | if ($winner || $prediction) { |
||
| 98 | return false; |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | // On passe au suivant si on a perdu |
||
| 103 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::GREATER) { |
||
| 104 | if (!$entry) { |
||
| 105 | return false; |
||
| 106 | } |
||
| 107 | if (!($entry->getPoints() > $missionGameCondition->getValue())) { |
||
| 108 | return false; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | // On passe au suivant si on a perdu |
||
| 113 | if ($missionGameCondition->getAttribute() == MissionGameConditionEntity::LESS) { |
||
| 114 | if (!$entry) { |
||
| 115 | return false; |
||
| 116 | } |
||
| 117 | if (!($entry->getPoints() < $missionGameCondition->getValue())) { |
||
| 118 | return false; |
||
| 119 | } |
||
| 120 | } |
||
| 121 | } |
||
| 122 | |||
| 123 | return $nextMissionGame->getGame(); |
||
| 124 | } |
||
| 125 | |||
| 185 |
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.