DeleteDirectory::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 12

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
dl 21
loc 21
rs 9.3142
c 0
b 0
f 0
cc 2
eloc 12
nc 2
nop 0
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