Socket   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A thatIsEncrypted() 0 7 1
A thatIsNotEncrypted() 0 7 1
A fromRemoteAddress() 0 7 1
A jsonSerialize() 0 7 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