DeleteDirectory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 50
loc 50
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 21 21 2
A setDirectory() 6 6 1
A getDirectory() 4 4 1

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
namespace Akeneo\Crowdin\Api;
4
5
use \InvalidArgumentException;
6
7
/**
8
 * Delete a directory from the Crowdin project. All nested files and directories will be deleted too.
9
 *
10
 * @author Julien Janvier <[email protected]>
11
 * @see https://crowdin.com/page/api/delete-directory
12
 */
13 View Code Duplication
class DeleteDirectory extends AbstractApi
0 ignored issues
show
Duplication introduced by
This class 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...
14
{
15
    /** @var string */
16
    protected $directory;
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function execute()
22
    {
23
        if (null == $this->directory) {
24
            throw new InvalidArgumentException('There is no directory to delete.');
25
        }
26
27
        $this->addUrlParameter('key', $this->client->getProjectApiKey());
28
        
29
        $path = sprintf(
30
            "project/%s/delete-directory?%s",
31
            $this->client->getProjectIdentifier(),
32
            $this->getUrlQueryString()
33
        );
34
35
        $parameters = ['name' => $this->directory];
36
37
        $data = ['form_params' => $parameters];
38
        $response = $this->client->getHttpClient()->post($path, $data);
39
40
        return $response->getBody();
41
    }
42
43
    /**
44
     * @param string $directory
45
     *
46
     * @return DeleteDirectory
47
     */
48
    public function setDirectory($directory)
49
    {
50
        $this->directory = $directory;
51
52
        return $this;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getDirectory()
59
    {
60
        return $this->directory;
61
    }
62
}
63