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

Statement::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
namespace Happyr\ApiClient\Api;
4
5
use Happyr\ApiClient\Assert;
6
use Psr\Http\Message\ResponseInterface;
7
use Happyr\ApiClient\Model\Statement\Statement as StatementModel;
8
9
/**
10
 * @author Tobias Nyholm <[email protected]>
11
 */
12
final class Statement extends HttpApi
13
{
14
    /**
15
     * @param $user
16
     * @param array $patterns
17
     * @param array $params   valid keys are limit and locale
18
     *
19
     * @return StatementModel|ResponseInterface
20
     */
21 View Code Duplication
    public function next($user, array $patterns, array $params)
0 ignored issues
show
Duplication introduced by
This method 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...
22
    {
23
        Assert::stringNotEmpty($user);
24
        Assert::notEmpty($patterns);
25
26
        $params['user'] = $user;
27
        $params['pattern'] = implode(',', $patterns);
28
29
        $response = $this->httpGet('/api/pattern/next-statement', $params);
30
31
        return $this->hydrateResponse($response, StatementModel::class);
32
    }
33
34
    /**
35
     * @param $user
36
     * @param array $patterns
37
     * @param $statement
38
     * @param $answer
39
     * @param array $params valid keys are locale
40
     *
41
     * @return StatementModel|ResponseInterface
42
     */
43
    public function answer($user, array $patterns, $statement, $answer, array $params)
44
    {
45
        Assert::stringNotEmpty($user);
46
        Assert::notEmpty($patterns);
47
48
        $params['user'] = $user;
49
        $params['pattern'] = implode(',', $patterns);
50
        $params['answer'] = $answer;
51
52
        $response = $this->httpGet(sprintf('/api/pattern/%s', $statement), $params);
53
54
        return $this->hydrateResponse($response, StatementModel::class);
55
    }
56
}
57