Completed
Push — master ( ff5b0d...faa513 )
by Tobias
05:10 queued 02:50
created

ProfilePattern::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Happyr\ApiClient\Api;
4
5
use Happyr\ApiClient\Assert;
6
use Happyr\ApiClient\Model\ProfilePattern\Created;
7
use Happyr\ApiClient\Model\ProfilePattern\Index;
8
use Psr\Http\Message\ResponseInterface;
9
10
/**
11
 * @author Tobias Nyholm <[email protected]>
12
 */
13
final class ProfilePattern extends HttpApi
14
{
15
    /**
16
     * @param string $lang
17
     *
18
     * @return Index|ResponseInterface
19
     */
20
    public function index($lang)
21
    {
22
        Assert::stringNotEmpty($lang);
23
24
        $response = $this->httpGet('/api/patterns', ['lang' => $lang]);
25
26
        return $this->hydrateResponse($response, Index::class);
27
    }
28
29
    /**
30
     * @param array $dimensions
31
     * @param $lang
32
     *
33
     * @return Created|ResponseInterface
34
     */
35
    public function create(array $dimensions, $lang)
36
    {
37
        Assert::notEmpty($dimensions);
38
        Assert::stringNotEmpty($lang);
39
40
        $response = $this->httpPost('/api/patterns/create', ['dimensions' => $dimensions, 'lang' => $lang]);
41
42
        return $this->hydrateResponse($response, Created::class);
43
    }
44
}
45