Passed
Push — master ( 434e9a...778819 )
by Nico
15:27 queued 08:32
created

TrojanHorseNotifier   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 11.11%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 31
ccs 2
cts 18
cp 0.1111
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A informUsersAboutTrojanHorse() 0 25 3
1
<?php
2
3
namespace Stu\Module\Spacecraft\Lib\Battle\AlertDetection;
4
5
use Doctrine\Common\Collections\Collection;
6
use Stu\Module\Message\Lib\PrivateMessageSenderInterface;
7
use Stu\Module\PlayerSetting\Lib\UserConstants;
0 ignored issues
show
Bug introduced by
The type Stu\Module\PlayerSetting\Lib\UserConstants 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...
8
use Stu\Orm\Entity\Spacecraft;
9
10
class TrojanHorseNotifier implements TrojanHorseNotifierInterface
11
{
12 1
    public function __construct(
13
        private PrivateMessageSenderInterface $privateMessageSender
14 1
    ) {}
15
16
    #[\Override]
17
    public function informUsersAboutTrojanHorse(
18
        Spacecraft $incomingSpacecraft,
19
        ?Spacecraft $tractoringSpacecraft,
20
        Collection $users
21
    ): void {
22
23
        if ($tractoringSpacecraft === null) {
24
            return;
25
        }
26
27
        $txt = sprintf(
28
            _('Die %s von Spieler %s ist in Sektor %s eingeflogen und hat dabei die %s von Spieler %s gezogen'),
29
            $tractoringSpacecraft->getName(),
30
            $tractoringSpacecraft->getUser()->getName(),
31
            $tractoringSpacecraft->getSectorString(),
32
            $incomingSpacecraft->getName(),
33
            $incomingSpacecraft->getUser()->getName()
34
        );
35
36
        foreach ($users as $user) {
37
            $this->privateMessageSender->send(
38
                UserConstants::USER_NOONE,
39
                $user->getId(),
40
                $txt
41
            );
42
        }
43
    }
44
}
45