Passed
Push — master ( 50ea2d...c8d4e9 )
by Janko
05:17
created

TrojanHorseNotifier::informUsersAboutTrojanHorse()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 7.8273

Importance

Changes 0
Metric Value
cc 3
eloc 15
nc 3
nop 3
dl 0
loc 25
ccs 3
cts 16
cp 0.1875
crap 7.8273
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
namespace Stu\Module\Spacecraft\Lib\Battle\AlertDetection;
4
5
use Doctrine\Common\Collections\Collection;
6
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...
7
use Stu\Module\Message\Lib\PrivateMessageSenderInterface;
8
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...
9
use Stu\Orm\Entity\Spacecraft;
10
11
class TrojanHorseNotifier implements TrojanHorseNotifierInterface
12
{
13 1
    public function __construct(
14
        private PrivateMessageSenderInterface $privateMessageSender
15 1
    ) {}
16
17 1
    #[Override]
18
    public function informUsersAboutTrojanHorse(
19
        Spacecraft $incomingSpacecraft,
20
        ?Spacecraft $tractoringSpacecraft,
21
        Collection $users
22
    ): void {
23
24 1
        if ($tractoringSpacecraft === null) {
25 1
            return;
26
        }
27
28
        $txt = sprintf(
29
            _('Die %s von Spieler %s ist in Sektor %s eingeflogen und hat dabei die %s von Spieler %s gezogen'),
30
            $tractoringSpacecraft->getName(),
31
            $tractoringSpacecraft->getUser()->getName(),
32
            $tractoringSpacecraft->getSectorString(),
33
            $incomingSpacecraft->getName(),
34
            $incomingSpacecraft->getUser()->getName()
35
        );
36
37
        foreach ($users as $user) {
38
            $this->privateMessageSender->send(
39
                UserConstants::USER_NOONE,
40
                $user->getId(),
41
                $txt
42
            );
43
        }
44
    }
45
}
46