MessageApi::extractMeaning()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
rs 9.4285
ccs 9
cts 9
cp 1
nc 2
cc 3
eloc 7
nop 3
crap 3
1
<?php
2
3
namespace Tgallice\Wit;
4
5
use Tgallice\Wit\Model\Context;
6
7
class MessageApi
8
{
9
    use ResponseHandler;
10
11
    /**
12
     * @var Client
13
     */
14
    private $client;
15
16 5
    public function __construct(Client $client)
17
    {
18 5
        $this->client = $client;
19 5
    }
20
21
    /**
22
     * @param string $text
23
     * @param Context|null $context
24
     * @param array $queryParams
25
     *
26
     * @return mixed
27
     */
28 2
    public function extractMeaning($text, Context $context = null, array $queryParams = [])
29
    {
30 2
        $query = array_merge($queryParams, [
31 2
            'q' => $text,
32 2
        ]);
33
34 2
        if (null !== $context && !$context->isEmpty()) {
35 1
            $query['context'] = json_encode($context);
36 1
        }
37
38 2
        $response = $this->client->get('/message', $query);
39
40 2
        return $this->decodeResponse($response);
41
    }
42
}
43