Passed
Push — master ( a53d55...43aca1 )
by Maximilian
03:50
created

Entity::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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