Passed
Push — master ( 749ee4...dbf6d0 )
by Maximilian
01:14
created

TextContent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 17
c 1
b 0
f 0
dl 0
loc 53
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 1
A jsonSerialize() 0 15 4
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Response\Directives\Display;
4
5
/**
6
 * @author Maximilian Beckers <[email protected]>
7
 */
8
class TextContent implements \JsonSerializable
9
{
10
    /**
11
     * @var Text|null
12
     */
13
    public $primaryText;
14
15
    /**
16
     * @var Text|null
17
     */
18
    public $secondaryText;
19
20
    /**
21
     * @var Text|null
22
     */
23
    public $tertiaryText;
24
25
    /**
26
     * @param Text|null $primaryText
27
     * @param Text|null $secondaryText
28
     * @param Text|null $tertiaryText
29
     *
30
     * @return TextContent
31
     */
32
    public static function create($primaryText = null, $secondaryText = null, $tertiaryText = null): self
33
    {
34
        $textContent = new self();
35
36
        $textContent->primaryText   = $primaryText;
37
        $textContent->secondaryText = $secondaryText;
38
        $textContent->tertiaryText  = $tertiaryText;
39
40
        return $textContent;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function jsonSerialize()
47
    {
48
        $data = new \ArrayObject();
49
50
        if (null !== $this->primaryText) {
51
            $data['primaryText'] = $this->primaryText;
52
        }
53
        if (null !== $this->secondaryText) {
54
            $data['secondaryText'] = $this->secondaryText;
55
        }
56
        if (null !== $this->tertiaryText) {
57
            $data['tertiaryText'] = $this->tertiaryText;
58
        }
59
60
        return $data;
61
    }
62
}
63