Passed
Pull Request — master (#1969)
by Janko
22:34 queued 10:03
created

EmergencyWrapper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 18
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A showDetails() 0 9 2
A __construct() 0 1 1
A get() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Spacecraft\Lib;
6
7
use Stu\Component\Player\Relation\PlayerRelationDeterminatorInterface;
8
use Stu\Orm\Entity\SpacecraftEmergencyInterface;
9
use Stu\Orm\Entity\UserInterface;
10
11
final class EmergencyWrapper
12
{
13
    public function __construct(private PlayerRelationDeterminatorInterface $playerRelationDeterminator, private SpacecraftEmergencyInterface $emergency, private UserInterface $user) {}
14
15
    public function get(): SpacecraftEmergencyInterface
16
    {
17
        return $this->emergency;
18
    }
19
20
    public function showDetails(): bool
21
    {
22
        $shipUser = $this->emergency->getSpacecraft()->getUser();
23
24
        if ($shipUser === $this->user) {
25
            return true;
26
        }
27
28
        return $this->playerRelationDeterminator->isFriend($this->user, $shipUser);
29
    }
30
}
31