| Conditions | 6 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | 4 | public function isEnemy(UserInterface $user, UserInterface $otherUser): bool |
|
| 27 | { |
||
| 28 | 4 | $alliance = $user->getAlliance(); |
|
| 29 | |||
| 30 | 4 | $otherUserAlliance = $otherUser->getAlliance(); |
|
| 31 | |||
| 32 | 4 | if ($alliance !== null && $otherUserAlliance !== null) { |
|
| 33 | 3 | if ($alliance === $otherUserAlliance) { |
|
| 34 | 1 | return false; |
|
| 35 | } |
||
| 36 | |||
| 37 | 2 | $result = $this->allianceRelationRepository->getActiveByTypeAndAlliancePair( |
|
| 38 | 2 | [ |
|
| 39 | 2 | AllianceEnum::ALLIANCE_RELATION_WAR, |
|
| 40 | 2 | ], |
|
| 41 | 2 | $otherUserAlliance->getId(), |
|
| 42 | 2 | $alliance->getId() |
|
| 43 | 2 | ); |
|
| 44 | |||
| 45 | 2 | if ($result !== null) { |
|
| 46 | 1 | return true; |
|
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | 2 | $contact = $this->contactRepository->getByUserAndOpponent( |
|
| 51 | 2 | $user->getId(), |
|
| 52 | 2 | $otherUser->getId() |
|
| 53 | 2 | ); |
|
| 54 | |||
| 55 | 2 | return $contact !== null && $contact->isEnemy(); |
|
| 56 | } |
||
| 58 |