Completed
Push — fix-checkstyle ( 525678...700890 )
by
unknown
03:06
created

Export::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
namespace Akeneo\Crowdin\Api;
4
5
/**
6
 * Build ZIP archive with the latest translations. Can be invoked only once for 30 minutes.
7
 *
8
 * @author Nicolas Dupont <[email protected]>
9
 * @see http://crowdin.net/page/api/export
10
 */
11
class Export extends AbstractApi
12
{
13
    /** @var string */
14
    protected $branch;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function execute()
20
    {
21
        $path = sprintf(
22
            "project/%s/export?key=%s",
23
            $this->client->getProjectIdentifier(),
24
            $this->client->getProjectApiKey()
25
        );
26
        if (null !== $this->branch) {
27
            $path = sprintf('%s&branch=%s', $path, $this->branch);
28
        }
29
        $request  = $this->client->getHttpClient()->get($path);
30
        $response = $request->send();
31
32
        return $response->getBody(true);
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getBranch()
39
    {
40
        return $this->branch;
41
    }
42
43
    /**
44
     * @param string $branch
45
     *
46
     * @return Export
47
     */
48
    public function setBranch($branch)
49
    {
50
        $this->branch = $branch;
51
52
        return $this;
53
    }
54
}
55