LayoutParameter::jsonSerialize()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 8
nc 4
nop 0
dl 0
loc 16
ccs 10
cts 10
cp 1
crap 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
class LayoutParameter implements \JsonSerializable
8
{
9 14
    public function __construct(
10
        public string $name,
11
        public mixed $default = null,
12
        public ?string $description = null,
13
        public LayoutParameterType $type = LayoutParameterType::ANY,
14
    ) {
15 14
    }
16
17 10
    public function jsonSerialize(): array
18
    {
19 10
        $data = [
20 10
            'name' => $this->name,
21 10
            'type' => $this->type,
22 10
        ];
23
24 10
        if ($this->default !== null) {
25 7
            $data['default'] = $this->default;
26
        }
27
28 10
        if ($this->description !== null) {
29 3
            $data['description'] = $this->description;
30
        }
31
32 10
        return $data;
33
    }
34
}
35