Passed
Push — dev ( 336cf2...bc410f )
by Janko
09:30
created

ColonyMember::getUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stu\Lib\Interaction\Member;
4
5
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Stu\Component\Anomaly\Type\AnomalyTypeEnum;
7
use Stu\Lib\Interaction\InteractionCheckType;
8
use Stu\Module\Ship\Lib\TholianWebUtilInterface;
9
use Stu\Orm\Entity\ColonyInterface;
10
use Stu\Orm\Entity\MapInterface;
11
use Stu\Orm\Entity\StarSystemMapInterface;
12
use Stu\Orm\Entity\UserInterface;
13
14
class ColonyMember implements InteractionMemberInterface
15
{
16 4
    public function __construct(
17
        private TholianWebUtilInterface $tholianWebUtil,
18
        private ColonyInterface $colony
19 4
    ) {}
20
21 2
    #[Override]
22
    public function get(): ColonyInterface
23
    {
24 2
        return $this->colony;
25
    }
26
27 2
    #[Override]
28
    public function canAccess(
29
        InteractionMemberInterface $other,
30
        callable $shouldCheck
31
    ): ?InteractionCheckType {
32 2
        return null;
33
    }
34
35 2
    #[Override]
36
    public function canBeAccessedFrom(
37
        InteractionMemberInterface $other,
38
        bool $isFriend,
39
        callable $shouldCheck
40
    ): ?InteractionCheckType {
41
42
        if (
43 2
            $shouldCheck(InteractionCheckType::EXPECT_TARGET_DOCKED_OR_NO_ION_STORM)
44 2
            && $this->colony->getLocation()->hasAnomaly(AnomalyTypeEnum::ION_STORM)
45
        ) {
46
            return InteractionCheckType::EXPECT_TARGET_DOCKED_OR_NO_ION_STORM;
47
        }
48
49
        if (
50 2
            $shouldCheck(InteractionCheckType::EXPECT_TARGET_ALSO_IN_FINISHED_WEB)
51 2
            && $this->tholianWebUtil->isTargetOutsideFinishedTholianWeb($other->get(), $this->colony)
52
        ) {
53
            return InteractionCheckType::EXPECT_TARGET_ALSO_IN_FINISHED_WEB;
54
        }
55
56 2
        return null;
57
    }
58
59 4
    #[Override]
60
    public function getLocation(): MapInterface|StarSystemMapInterface
61
    {
62 4
        return $this->colony->getLocation();
63
    }
64
65 4
    #[Override]
66
    public function getUser(): ?UserInterface
67
    {
68 4
        return $this->colony->getUser();
69
    }
70
}
71