System::atHost()   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 1
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 System implements JsonSerializable
10
{
11
    /**
12
     * @var string|null
13
     */
14
    private $architecture;
15
16
    /**
17
     * @var string|null
18
     */
19
    private $hostname;
20
21
    /**
22
     * @var string|null
23
     */
24
    private $platform;
25
26 1
    public function onArchitecture(string $architecture): self
27
    {
28 1
        $me               = clone $this;
29 1
        $me->architecture = $architecture;
30
31 1
        return $me;
32
    }
33
34 31
    public function atHost(string $hostname): self
35
    {
36 31
        $me           = clone $this;
37 31
        $me->hostname = $hostname;
38
39 31
        return $me;
40
    }
41
42 1
    public function onPlatform(string $platform): self
43
    {
44 1
        $me           = clone $this;
45 1
        $me->platform = $platform;
46
47 1
        return $me;
48
    }
49
50
    /**
51
     * @return mixed[]
52
     */
53 26
    public function jsonSerialize(): array
54
    {
55 26
        return Serialization::filterUnset([
56 26
            'hostname' => $this->hostname,
57 26
            'architecture' => $this->architecture,
58 26
            'platform' => $this->platform,
59
        ]);
60
    }
61
}
62