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

Profile::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 7
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
        return [
24
            'xhprof' => $this->xhprof ?? [],
25
            'xdebug' => $this->xdebug ?? [],
26
            'php' => $this->php ?? ['backtrace' => []],
27
        ];
28
    }
29
}
30