GetLanguagesForSpeak::getRequestOptions()   A
last analyzed

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 0
crap 1
1
<?php
2
/**
3
 * This file is part of the badams\MicrosoftTranslator library
4
 *
5
 * @license http://opensource.org/licenses/MIT
6
 * @link https://github.com/badams/microsoft-translator
7
 * @package badams/microsoft-translator
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace badams\MicrosoftTranslator\Methods;
14
15
use badams\MicrosoftTranslator\Language;
16
17
/**
18
 * Class GetLanguagesForSpeak
19
 * @package badams\MicrosoftTranslator\Methods
20
 * @link https://msdn.microsoft.com/en-us/library/ff512415.aspx
21
 */
22
class GetLanguagesForSpeak implements \badams\MicrosoftTranslator\ApiMethodInterface
23
{
24
    /**
25
     * @return string
26
     */
27 3
    public function getRequestMethod()
28
    {
29 3
        return 'GET';
30
    }
31
32
    /**
33
     * @return array
34
     */
35 3
    public function getRequestOptions()
36
    {
37 3
        return [];
38
    }
39
40
    /**
41
     * @param \GuzzleHttp\Message\ResponseInterface $response
42
     * @return Language[]
43
     */
44 3
    public function processResponse(\GuzzleHttp\Message\ResponseInterface $response)
45
    {
46 3
        $xml = simplexml_load_string($response->getBody()->getContents());
47
48 3
        $languages = [];
49
50 3
        foreach ($xml->string as $language) {
51 3
            $languages[] = (string)$language;
52 3
        }
53
54 3
        return $languages;
55
    }
56
}
57