1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Message; |
6
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
8
|
|
|
use Stu\Lib\Information\InformationWrapper; |
9
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
10
|
|
|
|
11
|
|
|
final class MessageCollection implements MessageCollectionInterface |
12
|
|
|
{ |
13
|
|
|
/** @var MessageInterface[] */ |
14
|
|
|
private array $messages = []; |
15
|
|
|
|
16
|
5 |
|
public function __construct(private MessageFactoryInterface $messageFactory) {} |
17
|
|
|
|
18
|
5 |
|
#[Override] |
19
|
|
|
public function add(MessageInterface $msg): void |
20
|
|
|
{ |
21
|
5 |
|
$this->messages[] = $msg; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
#[Override] |
25
|
|
|
public function addInformation(string $text, ?int $recipient = null): MessageInterface |
26
|
|
|
{ |
27
|
|
|
$message = $this->messageFactory->createMessage( |
28
|
|
|
UserEnum::USER_NOONE, |
29
|
|
|
$recipient, |
30
|
|
|
[$text] |
31
|
|
|
); |
32
|
|
|
|
33
|
|
|
$this->add($message); |
34
|
|
|
|
35
|
|
|
return $message; |
36
|
|
|
} |
37
|
|
|
|
38
|
1 |
|
#[Override] |
39
|
|
|
public function getRecipientIds(): array |
40
|
|
|
{ |
41
|
1 |
|
$recipientIds = []; |
42
|
|
|
|
43
|
1 |
|
foreach ($this->messages as $message) { |
44
|
1 |
|
if ($message->isEmpty()) { |
45
|
|
|
continue; |
46
|
|
|
} |
47
|
|
|
|
48
|
1 |
|
$recipientId = $message->getRecipientId(); |
49
|
|
|
|
50
|
1 |
|
if ($recipientId === null || $recipientId === UserEnum::USER_NOONE) { |
51
|
1 |
|
continue; |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
if (!in_array($recipientId, $recipientIds)) { |
55
|
1 |
|
$recipientIds[] = $recipientId; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
1 |
|
return $recipientIds; |
60
|
|
|
} |
61
|
|
|
|
62
|
4 |
|
#[Override] |
63
|
|
|
public function getInformationDump(?int $userId = null): InformationWrapper |
64
|
|
|
{ |
65
|
4 |
|
$result = new InformationWrapper(); |
66
|
|
|
|
67
|
4 |
|
foreach ($this->messages as $message) { |
68
|
4 |
|
if ($message->isEmpty()) { |
69
|
1 |
|
continue; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if ( |
73
|
3 |
|
$userId === null |
74
|
1 |
|
|| $message->getSenderId() === $userId |
75
|
1 |
|
|| $message->getRecipientId() === null |
76
|
3 |
|
|| $message->getRecipientId() === $userId |
77
|
|
|
) { |
78
|
3 |
|
$result->addInformationArray($message->getMessage()); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
4 |
|
return $result; |
83
|
|
|
} |
84
|
|
|
|
85
|
2 |
|
#[Override] |
86
|
|
|
public function isEmpty(): bool |
87
|
|
|
{ |
88
|
2 |
|
return $this->getInformationDump()->isEmpty(); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths