Passed
Pull Request — 1.x (#334)
by Akihito
02:26
created

Profile::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\SemanticLog\Profile;
6
7
use JsonSerializable;
8
use Override;
9
10
final class Profile implements JsonSerializable
11
{
12
    public function __construct(
13
        public ?XHProfResult $xhprof = null,
14
        public ?XdebugTrace $xdebug = null,
15
        public ?PhpProfile $php = null,
16
    ) {
17
    }
18
19
    /** @return array<string, mixed> */
20
    #[Override]
21
    public function jsonSerialize(): array
22
    {
23
        $data = [];
24
25
        if ($this->xhprof !== null) {
26
            $data['xhprof'] = $this->xhprof;
27
        }
28
29
        if ($this->xdebug !== null) {
30
            $data['xdebug'] = $this->xdebug;
31
        }
32
33
        if ($this->php !== null) {
34
            $data['php'] = $this->php;
35
        }
36
37
        return $data;
38
    }
39
}
40