OutputSpeech   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
dl 0
loc 54
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A createByText() 0 7 1
A createBySsml() 0 7 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