Completed
Push — master ( 08753a...42665f )
by Sascha-Oliver
05:38
created

Locale::download()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 4
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license.  See the LICENSE file for details.
8
 */
9
10
namespace FAPI\PhraseApp\Api;
11
12
use FAPI\PhraseApp\Exception;
13
use Psr\Http\Message\ResponseInterface;
14
15
/**
16
 * @author Sascha-Oliver Prolic <[email protected]>
17
 */
18
class Locale extends HttpApi
19
{
20
    /**
21
     * Download a locale.
22
     *
23
     * @param string $projectKey
24
     * @param string $localeId
25
     * @param string $ext
26
     * @param array  $params
27
     *
28
     * @throws Exception
29
     *
30
     * @return string|ResponseInterface
31
     */
32 View Code Duplication
    public function download(string $projectKey, string $localeId, string $ext, array $params = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $params['file_format'] = $ext;
35
36
        $response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/download', $projectKey, $localeId), $params);
37
38
        if (!$this->hydrator) {
39
            return $response;
40
        }
41
42
        if ($response->getStatusCode() !== 200) {
43
            $this->handleErrors($response);
44
        }
45
46
        return (string) $response->getBody();
47
    }
48
}
49