Export::setBranch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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 https://crowdin.com/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
        $this->addUrlParameter('key', $this->client->getProjectApiKey());
22
        
23
        $path = sprintf(
24
            "project/%s/export?%s",
25
            $this->client->getProjectIdentifier(),
26
            $this->getUrlQueryString()
27
        );
28
        if (null !== $this->branch) {
29
            $path = sprintf('%s&branch=%s', $path, $this->branch);
30
        }
31
        $response = $this->client->getHttpClient()->get($path);
32
33
        return $response->getBody();
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getBranch()
40
    {
41
        return $this->branch;
42
    }
43
44
    /**
45
     * @param string $branch
46
     *
47
     * @return Export
48
     */
49
    public function setBranch($branch)
50
    {
51
        $this->branch = $branch;
52
53
        return $this;
54
    }
55
}
56