Completed
Push — master ( eb5568...bc1b58 )
by Nicolas
9s
created

DeleteFile::getFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Akeneo\Crowdin\Api;
4
5
/**
6
 * Deletes a file from a Crowdin project. All the translations will be lost without ability to restore them.
7
 *
8
 * @author Julien Janvier <[email protected]>
9
 * @see http://crowdin.net/page/api/delete-file
10
 */
11 View Code Duplication
class DeleteFile 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...
12
{
13
    protected $file;
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function execute()
19
    {
20
        if (null == $this->getFile()) {
21
            throw new \InvalidArgumentException('There is no file to delete.');
22
        }
23
24
        $path = sprintf(
25
            "project/%s/delete-file?key=%s",
26
            $this->client->getProjectIdentifier(),
27
            $this->client->getProjectApiKey()
28
        );
29
30
        $parameters = array_merge($this->parameters, array('file' => $this->getFile()));
31
32
        $request  = $this->client->getHttpClient()->post($path, array(), $parameters);
33
        $response = $request->send();
34
35
        return $response->getBody(true);
36
    }
37
38
    /**
39
     * @param mixed $file
40
     */
41
    public function setFile($file)
42
    {
43
        $this->file = $file;
44
    }
45
46
    /**
47
     * @return mixed
48
     */
49
    public function getFile()
50
    {
51
        return $this->file;
52
    }
53
}
54