Locale::download()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 0
cts 10
cp 0
rs 9.7333
c 0
b 0
f 0
cc 3
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\Client\ClientExceptionInterface;
14
use Psr\Http\Message\ResponseInterface;
15
16
/**
17
 * @author Sascha-Oliver Prolic <[email protected]>
18
 */
19
class Locale extends HttpApi
20
{
21
    /**
22
     * Download a locale.
23
     *
24
     * @param string $projectKey
25
     * @param string $localeId
26
     * @param string $ext
27
     * @param array  $params
28
     *
29
     * @throws ClientExceptionInterface
30
     * @throws Exception\DomainException
31
     *
32
     * @return string|ResponseInterface
33
     */
34 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...
35
    {
36
        $params['file_format'] = $ext;
37
38
        $response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/download', $projectKey, $localeId), $params);
39
40
        if (!$this->hydrator) {
41
            return $response;
42
        }
43
44
        if ($response->getStatusCode() !== 200) {
45
            $this->handleErrors($response);
46
        }
47
48
        return (string) $response->getBody();
49
    }
50
}
51