Completed
Push — master ( c28851...781c6a )
by Tobias
02:28
created

Export::locale()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 4
crap 12
1
<?php
2
3
/*
4
 *
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license.  See the LICENSE file for details.
8
 */
9
10
namespace FAPI\Localise\Api;
11
12
use Psr\Http\Message\ResponseInterface;
13
use FAPI\Localise\Exception;
14
15
/**
16
 * @author Tobias Nyholm <[email protected]>
17
 */
18
class Export extends HttpApi
19
{
20
    /**
21
     * Export a locale.
22
     * {@link https://localise.biz/api/docs/export/exportlocale}.
23
     *
24
     * @param string $projectKey
25
     * @param string $locale
26
     * @param string $ext
27
     * @param array  $params
28
     *
29
     * @return string|ResponseInterface
30
     *
31
     * @throws Exception
32
     */
33
    public function locale(string $projectKey, string $locale, string $ext, array $params)
34
    {
35
        $params['key'] = $projectKey;
36
        $response = $this->httpGet(sprintf('/api/export/locale/%s.%s?%s', $locale, $ext, http_build_query($params)));
37
38
        if (!$this->hydrator) {
39
            return $response;
40
        }
41
42
        if ($response->getStatusCode() !== 200) {
43
            $this->handleErrors($response);
44
        }
45
46
        return (string) $response->getBody();
47
    }
48
}
49