NoteResultData::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Module\Note\List\Data;
4
5
use App\Module\Note\Data\NoteData;
6
7
/**
8
 * Note with user and client full name and privilege.
9
 */
10
class NoteResultData extends NoteData
11
{
12
    public ?string $userFullName;
13
    public ?string $clientFullName;
14
    public ?bool $isClientMessage = false;
15
16
    // Populated in NoteUserRightSetter
17
    public string $privilege; // json_encode automatically takes $enum->value
18
19 8
    public function __construct(array $noteValues = [])
20
    {
21 8
        parent::__construct($noteValues);
22
23 8
        $this->userFullName = $noteValues['user_full_name'] ?? null;
24 8
        $this->clientFullName = $noteValues['client_full_name'] ?? null;
25
    }
26
27 8
    public function jsonSerialize(): array
28
    {
29 8
        return array_merge(parent::jsonSerialize(), [
30 8
            'userFullName' => $this->userFullName,
31 8
            'clientFullName' => $this->clientFullName,
32 8
            'privilege' => $this->privilege,
33 8
            'isClientMessage' => (int)$this->isClientMessage,
34 8
        ]);
35
    }
36
}
37