Completed
Push — master ( 6d8a2a...3743ea )
by Byron
02:34
created

Speak::processResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace badams\MicrosoftTranslator\Methods;
4
5
/**
6
 * Class Speak
7
 * @package badams\MicrosoftTranslator\Methods
8
 * @link https://msdn.microsoft.com/en-us/library/ff512420.aspx
9
 */
10
class Speak implements \badams\MicrosoftTranslator\ApiMethodInterface
11
{
12
    const FORMAT_MP3 = 'audio/mp3';
13
    const FORMAT_WAV = 'audio/wav';
14
15
    const OPTION_MAX_QUALITY = 'MaxQuality';
16
    const OPTION_MIN_SIZE = 'MinSize';
17
18
    /**
19
     * @var string
20
     */
21
    protected $language;
22
23
    /**
24
     * @var string
25
     */
26
    protected $text;
27
28
    /**
29
     * @var string
30
     */
31
    protected $format;
32
33
    /**
34
     * @var string
35
     */
36
    protected $options;
37
38
    /**
39
     * Translate constructor.
40
     * @param $text
41
     * @param $to
42
     * @param null $from
0 ignored issues
show
Bug introduced by
There is no parameter named $from. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
43
     */
44 3
    public function __construct($text, $language, $format = Speak::FORMAT_MP3, $options = Speak::OPTION_MAX_QUALITY)
45
    {
46 3
        $this->text = $text;
47 3
        $this->language = $language;
48 3
        $this->format = $format;
49 3
        $this->options = $options;
50 3
    }
51
52
    /**
53
     * @return string
54
     */
55 3
    public function getRequestMethod()
56
    {
57 3
        return 'GET';
58
    }
59
60
    /**
61
     * @return array
62
     */
63 3
    public function getRequestOptions()
64
    {
65
        return ['query' => [
66 3
            'text' => $this->text,
67 3
            'language' => $this->language,
68 3
            'format' => $this->format,
69 3
            'options' => $this->options,
70 3
        ]];
71
    }
72
73
    /**
74
     * @param \GuzzleHttp\Message\ResponseInterface $response
75
     * @return string
76
     */
77 3
    public function processResponse(\GuzzleHttp\Message\ResponseInterface $response)
78
    {
79 3
        return base64_encode($response->getBody()->getContents());
80
    }
81
82
83
}