Passed
Push — dev ( 0aa780...31f66c )
by Janko
11:20
created

ColonyMember   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 48
ccs 12
cts 15
cp 0.8
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A canBeAccessedFrom() 0 15 3
A get() 0 4 1
A getUser() 0 4 1
A getLocation() 0 4 1
A canAccess() 0 6 1
A __construct() 0 4 1
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\Lib\Interaction\InteractionCheckType;
7
use Stu\Module\Ship\Lib\TholianWebUtilInterface;
8
use Stu\Orm\Entity\ColonyInterface;
9
use Stu\Orm\Entity\MapInterface;
10
use Stu\Orm\Entity\StarSystemMapInterface;
11
use Stu\Orm\Entity\UserInterface;
12
13
class ColonyMember implements InteractionMemberInterface
14
{
15 4
    public function __construct(
16
        private TholianWebUtilInterface $tholianWebUtil,
17
        private ColonyInterface $colony
18 4
    ) {}
19
20
    #[Override]
21
    public function get(): ColonyInterface
22
    {
23
        return $this->colony;
24
    }
25
26 2
    #[Override]
27
    public function canAccess(
28
        InteractionMemberInterface $other,
29
        callable $shouldCheck
30
    ): ?InteractionCheckType {
31 2
        return null;
32
    }
33
34 2
    #[Override]
35
    public function canBeAccessedFrom(
36
        InteractionMemberInterface $other,
37
        bool $isFriend,
38
        callable $shouldCheck
39
    ): ?InteractionCheckType {
40
41
        if (
42 2
            $shouldCheck(InteractionCheckType::EXPECT_TARGET_ALSO_IN_FINISHED_WEB)
43 2
            && $this->tholianWebUtil->isTargetOutsideFinishedTholianWeb($other->get(), $this->colony)
44
        ) {
45
            return InteractionCheckType::EXPECT_TARGET_ALSO_IN_FINISHED_WEB;
46
        }
47
48 2
        return null;
49
    }
50
51 4
    #[Override]
52
    public function getLocation(): MapInterface|StarSystemMapInterface
53
    {
54 4
        return $this->colony->getLocation();
55
    }
56
57 4
    #[Override]
58
    public function getUser(): ?UserInterface
59
    {
60 4
        return $this->colony->getUser();
61
    }
62
}
63