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

Speak   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 74
ccs 16
cts 16
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getRequestMethod() 0 4 1
A getRequestOptions() 0 9 1
A processResponse() 0 4 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
}