Passed
Push — dev ( 0f4afd...29c427 )
by Janko
25:18 queued 14:48
created

Conversation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 6
dl 0
loc 13
ccs 6
cts 6
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Game\Lib\View\Provider\Message;
6
7
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...
8
use Stu\Module\Message\Lib\PrivateMessageListItem;
9
use Stu\Orm\Entity\PrivateMessageInterface;
10
use Stu\Orm\Entity\UserInterface;
11
use Stu\Orm\Repository\ContactRepositoryInterface;
12
use Stu\Orm\Repository\PrivateMessageRepositoryInterface;
13
14
final class Conversation extends PrivateMessageListItem
15
{
16 1
    public function __construct(
17
        private PrivateMessageInterface $message,
18
        private int $unreadPmCount,
19
        private string $dateString,
20
        UserInterface $currentUser,
21
        PrivateMessageRepositoryInterface $privateMessageRepository,
22
        ContactRepositoryInterface $contactRepository
23
    ) {
24 1
        parent::__construct(
25 1
            $privateMessageRepository,
26 1
            $contactRepository,
27 1
            $message,
28 1
            $currentUser
29 1
        );
30
    }
31
32 1
    #[Override]
33
    public function isMarkableAsNew(): bool
34
    {
35 1
        return $this->message->getNew();
36
    }
37
38 1
    public function getUnreadMessageCount(): int
39
    {
40 1
        return $this->unreadPmCount;
41
    }
42
43 1
    public function getLastHeadline(): string
44
    {
45 1
        return sprintf(
46 1
            '%s%s',
47 1
            $this->message->getInboxPm() === null ? sprintf(
48 1
                '%s: ',
49 1
                $this->getOtherUser()->getName()
50 1
            ) : '',
51 1
            substr($this->message->getText(), 0, 200)
52 1
        );
53
    }
54
55 1
    public function getOtherUser(): UserInterface
56
    {
57 1
        return $this->message->getSender();
58
    }
59
60 1
    public function getDateString(): string
61
    {
62 1
        return $this->dateString;
63
    }
64
}
65