Socket::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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 Socket implements JsonSerializable
10
{
11
    /**
12
     * @var bool|null
13
     */
14
    private $isEncrypteo;
15
16
    /**
17
     * @var string|null
18
     */
19
    private $remoteAddress;
20
21 2
    public function thatIsEncrypted(): self
22
    {
23 2
        $me              = clone $this;
24 2
        $me->isEncrypteo = true;
25
26 2
        return $me;
27
    }
28
29 1
    public function thatIsNotEncrypted(): self
30
    {
31 1
        $me              = clone $this;
32 1
        $me->isEncrypteo = false;
33
34 1
        return $me;
35
    }
36
37 1
    public function fromRemoteAddress(string $remoteAddress): self
38
    {
39 1
        $me                = clone $this;
40 1
        $me->remoteAddress = $remoteAddress;
41
42 1
        return $me;
43
    }
44
45
    /**
46
     * @return mixed[]
47
     */
48 4
    public function jsonSerialize(): array
49
    {
50 4
        return Serialization::filterUnset([
51 4
            'remote_address' => $this->remoteAddress,
52 4
            'encrypted' => $this->isEncrypteo,
53
        ]);
54
    }
55
}
56