Passed
Push — master ( ffee1f...e53f62 )
by Samuel
03:34
created

ClientReadResult::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Domain\Client\Data;
4
5
use App\Domain\Note\Data\NoteData;
6
7
/** Aggregate DTO to store data for client read page */
8
class ClientReadResult extends ClientData
9
{
10
    // Amount of notes for the client to know how many skeleton loaders to display
11
    public ?int $notesAmount = null;
12
13
    // Main note data
14
    public ?NoteData $mainNoteData = null;
15
16
    // If allowed to change personal client values i.e. first name, last name, location, birthdate
17
    public ?string $generalPrivilege = null;
18
    public ?string $clientStatusPrivilege = null;
19
    public ?string $assignedUserPrivilege = null;
20
    public ?string $noteCreationPrivilege = null;
21
22 3
    public function __construct(array $clientResultData = [])
23
    {
24 3
        parent::__construct($clientResultData);
25
26
        // Populate mainNote if set
27 3
        $this->mainNoteData = new NoteData([
28 3
            'id' => $clientResultData['main_note_id'] ?? null,
29 3
            'message' => $clientResultData['note_message'] ?? null,
30 3
            'hidden' => $clientResultData['note_hidden'] ?? null,
31 3
            'user_id' => $clientResultData['note_user_id'] ?? null,
32 3
            'updated_at' => $clientResultData['note_updated_at'] ?? null,
33 3
        ]);
34
    }
35
}
36