UserResultData   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 29
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 6 1
1
<?php
2
3
namespace App\Module\User\Data;
4
5
class UserResultData extends UserData
6
{
7
    public ?string $generalPrivilege = null;
8
    // If the authenticated user is allowed to change status
9
    public ?string $statusPrivilege = null;
10
    // If the authenticated user is allowed to change the password without having to type in the old password
11
    public ?string $passwordWithoutVerificationPrivilege = null;
12
13
    // If the authenticated user is allowed to change role
14
    public ?string $userRolePrivilege = null;
15
16
    // Authorization limits which entries are in the user role dropdown
17
    public array $availableUserRoles = [];
18
19
    /**
20
     * Not all object attributes should be passed to view.
21
     * This function like the toArrayForDatabase returns only
22
     * the relevant attributes.
23
     * Private attributes could also be used as they are not
24
     * serialized by json_encode, but it's a harder to hydrate a
25
     * collection of results.
26
     * It has also an added benefit of exactly controlling what and how its serialized.
27
     */
28 4
    public function jsonSerialize(): array
29
    {
30 4
        return array_merge(parent::jsonSerialize(), [
31 4
            'statusPrivilege' => $this->statusPrivilege,
32 4
            'userRolePrivilege' => $this->userRolePrivilege,
33 4
            'availableUserRoles' => $this->availableUserRoles,
34 4
        ]);
35
    }
36
}
37