Locale   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 50 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 16
loc 32
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A download() 16 16 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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