Process   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 64
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
ccs 21
cts 21
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A withParentProcessId() 0 7 1
A titled() 0 7 1
A withArguments() 0 7 1
A jsonSerialize() 0 9 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TechDeCo\ElasticApmAgent\Message;
5
6
use JsonSerializable;
7
use TechDeCo\ElasticApmAgent\Serialization;
8
use function array_merge;
9
10
final class Process implements JsonSerializable
11
{
12
    /**
13
     * @var int
14
     */
15
    private $processId;
16
17
    /**
18
     * @var int|null
19
     */
20
    private $parentProcessId;
21
22
    /**
23
     * @var string|null
24
     */
25
    private $title;
26
27
    /**
28
     * @var string[]
29
     */
30
    private $argumentList = [];
31
32 32
    public function __construct(int $processId)
33
    {
34 32
        $this->processId = $processId;
35 32
    }
36
37 1
    public function withParentProcessId(int $id): self
38
    {
39 1
        $me                  = clone $this;
40 1
        $me->parentProcessId = $id;
41
42 1
        return $me;
43
    }
44
45 1
    public function titled(string $title): self
46
    {
47 1
        $me        = clone $this;
48 1
        $me->title = $title;
49
50 1
        return $me;
51
    }
52
53 1
    public function withArguments(string ...$argument): self
54
    {
55 1
        $me               = clone $this;
56 1
        $me->argumentList = array_merge($me->argumentList, $argument);
57
58 1
        return $me;
59
    }
60
61
    /**
62
     * @return mixed[]
63
     */
64 26
    public function jsonSerialize(): array
65
    {
66 26
        return Serialization::filterUnset([
67 26
            'pid' => $this->processId,
68 26
            'ppid' => $this->parentProcessId,
69 26
            'title' => $this->title,
70 26
            'argv' => $this->argumentList,
71
        ]);
72
    }
73
}
74