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

Locale   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 51.61 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 16
loc 31
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\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