User   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 56
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1
ccs 17
cts 17
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A withId() 0 7 1
A withEmail() 0 7 1
A withUsername() 0 7 1
A jsonSerialize() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TechDeCo\ElasticApmAgent\Message;
5
6
use JsonSerializable;
7
use TechDeCo\ElasticApmAgent\Serialization;
8
9
final class User implements JsonSerializable
10
{
11
    /**
12
     * @var string|int|null
13
     */
14
    private $id;
15
16
    /**
17
     * @var string|null
18
     */
19
    private $email;
20
21
    /**
22
     * @var string
23
     */
24
    private $username;
25
26
    /**
27
     * @param string|int $id
28
     */
29 2
    public function withId($id): self
30
    {
31 2
        $me     = clone $this;
32 2
        $me->id = $id;
33
34 2
        return $me;
35
    }
36
37 1
    public function withEmail(string $email): self
38
    {
39 1
        $me        = clone $this;
40 1
        $me->email = $email;
41
42 1
        return $me;
43
    }
44
45 1
    public function withUsername(string $username): self
46
    {
47 1
        $me           = clone $this;
48 1
        $me->username = $username;
49
50 1
        return $me;
51
    }
52
53
    /**
54
     * @return mixed[]
55
     */
56 3
    public function jsonSerialize(): array
57
    {
58 3
        return Serialization::filterUnset([
59 3
            'id' => $this->id,
60 3
            'email' => $this->email,
61 3
            'username' => $this->username,
62
        ]);
63
    }
64
}
65