TypeValue::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 3
crap 1
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 3
    public static function create(string $id, string $value, array $synonyms = []): self
30
    {
31 3
        $typeValue = new self();
32
33 3
        $typeValue->id       = $id;
34 3
        $typeValue->value    = $value;
35 3
        $typeValue->synonyms = $synonyms;
36
37 3
        return $typeValue;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 3
    public function jsonSerialize()
44
    {
45 3
        return [
46 3
            'id'   => $this->id,
47 3
            'name' => [
48 3
                'value'    => $this->value,
49 3
                'synonyms' => $this->synonyms,
50 3
            ],
51 3
        ];
52
    }
53
}
54