1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Game\Lib\View\Provider\Message; |
6
|
|
|
|
7
|
|
|
use Stu\Component\Game\TimeConstants; |
|
|
|
|
8
|
|
|
use Stu\Module\Control\StuTime; |
9
|
|
|
use Stu\Module\Message\Lib\PrivateMessageListItem; |
10
|
|
|
use Stu\Orm\Entity\PrivateMessageInterface; |
11
|
|
|
use Stu\Orm\Entity\UserInterface; |
12
|
|
|
use Stu\Orm\Repository\ContactRepositoryInterface; |
13
|
|
|
use Stu\Orm\Repository\PrivateMessageRepositoryInterface; |
14
|
|
|
|
15
|
|
|
final class Conversation extends PrivateMessageListItem |
16
|
|
|
{ |
17
|
|
|
public function __construct( |
18
|
|
|
private PrivateMessageInterface $message, |
19
|
|
|
private int $time, |
20
|
|
|
private StuTime $stuTime, |
21
|
|
|
int $currentUserId, |
22
|
|
|
PrivateMessageRepositoryInterface $privateMessageRepository, |
23
|
|
|
ContactRepositoryInterface $contactRepository |
24
|
|
|
) { |
25
|
|
|
parent::__construct( |
26
|
|
|
$privateMessageRepository, |
27
|
|
|
$contactRepository, |
28
|
|
|
$message, |
29
|
|
|
$currentUserId |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function getLastHeadline(): string |
34
|
|
|
{ |
35
|
|
|
return sprintf( |
36
|
|
|
'%s%s', |
37
|
|
|
$this->message->getInboxPm() === null ? sprintf( |
38
|
|
|
'%s: ', |
39
|
|
|
$this->getOtherUser()->getName() |
40
|
|
|
) : '', |
41
|
|
|
substr($this->message->getText(), 0, 200) |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getOtherUser(): UserInterface |
46
|
|
|
{ |
47
|
|
|
return $this->message->getSender(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getDateString(): string |
51
|
|
|
{ |
52
|
|
|
//TODO move code to MessengerStyleProvider and inject as constructor parameter |
53
|
|
|
$messageTimestamp = $this->message->getDate(); |
54
|
|
|
$distanceInSeconds = $this->time - $messageTimestamp; |
55
|
|
|
|
56
|
|
|
if ($distanceInSeconds < TimeConstants::ONE_DAY_IN_SECONDS) { |
57
|
|
|
return date("H:i", $messageTimestamp); |
58
|
|
|
} |
59
|
|
|
if ($distanceInSeconds < TimeConstants::SEVEN_DAYS_IN_SECONDS) { |
60
|
|
|
return match ((int)date("N", $messageTimestamp)) { |
61
|
|
|
1 => 'Montag', |
62
|
|
|
2 => 'Dienstag', |
63
|
|
|
3 => 'Mittwoch', |
64
|
|
|
4 => 'Donnerstag', |
65
|
|
|
5 => 'Freitag', |
66
|
|
|
6 => 'Samstag', |
67
|
|
|
7 => 'Sonntag' |
68
|
|
|
}; |
69
|
|
|
} |
70
|
|
|
return $this->stuTime->transformToStuDate($messageTimestamp); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
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