Passed
Push — master ( fd08ce...6743ff )
by Maximilian
01:01 queued 10s
created

TypeValue::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Response\Directives\Dialog\Entity;
4
5
class TypeValue implements \JsonSerializable
6
{
7
    /**
8
     * @var string
9
     */
10
    public $id;
11
12
    /**
13
     * @var string
14
     */
15
    public $value;
16
17
    /**
18
     * @var array
19
     */
20
    public $synonyms;
21
22
    /**
23
     * @param string $id
24
     * @param string $value
25
     * @param array  $synonyms
26
     *
27
     * @return TypeValue
28
     */
29
    public static function create(string $id, string $value, array $synonyms = []): self
30
    {
31
        $typeValue = new self();
32
33
        $typeValue->id       = $id;
34
        $typeValue->value    = $value;
35
        $typeValue->synonyms = $synonyms;
36
37
        return $typeValue;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function jsonSerialize()
44
    {
45
        return [
46
            'id'   => $this->id,
47
            'name' => [
48
                'value'    => $this->value,
49
                'synonyms' => $this->synonyms,
50
            ],
51
        ];
52
    }
53
}
54