Passed
Pull Request — master (#97)
by Maximilian
04:02
created

Parameter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
dl 0
loc 29
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 1
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 19 4
A __construct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
class Parameter implements \JsonSerializable
8
{
9 15
    public function __construct(
10
        public string $name,
11
        public mixed $default = null,
12
        public ?string $description = null,
13
        public ?ParameterType $type = null,
14
    ) {
15 15
    }
16
17 11
    public function jsonSerialize(): array
18
    {
19 11
        $data = [
20 11
            'name' => $this->name,
21 11
        ];
22
23 11
        if ($this->type !== null) {
24 6
            $data['type'] = $this->type;
25
        }
26
27 11
        if ($this->default !== null) {
28 8
            $data['default'] = $this->default;
29
        }
30
31 11
        if ($this->description !== null) {
32 4
            $data['description'] = $this->description;
33
        }
34
35 11
        return $data;
36
    }
37
}
38