OutputSpeech::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Response;
4
5
/**
6
 * @author Maximilian Beckers <[email protected]>
7
 */
8
class OutputSpeech
9
{
10
    const TYPE_PLAINTEXT = 'PlainText';
11
    const TYPE_SSML      = 'SSML';
12
13
    /**
14
     * @var string
15
     */
16
    public $type;
17
18
    /**
19
     * @var string
20
     */
21
    public $text;
22
23
    /**
24
     * @var string
25
     */
26
    public $ssml;
27
28
    /**
29
     * @param string $type
30
     */
31 7
    public function __construct(string $type = self::TYPE_PLAINTEXT)
32
    {
33 7
        $this->type = $type;
34
    }
35
36
    /**
37
     * @param string $test
38
     *
39
     * @return OutputSpeech
40
     */
41 3
    public static function createByText(string $test): self
42
    {
43 3
        $outputSpeech = new self();
44
45 3
        $outputSpeech->text = $test;
46
47 3
        return $outputSpeech;
48
    }
49
50
    /**
51
     * @param string $ssml
52
     *
53
     * @return OutputSpeech
54
     */
55 3
    public static function createBySsml(string $ssml): self
56
    {
57 3
        $outputSpeech = new self(self::TYPE_SSML);
58
59 3
        $outputSpeech->ssml = $ssml;
60
61 3
        return $outputSpeech;
62
    }
63
}
64