Completed
Push — master ( aef33f...952551 )
by Gallice
51s queued 10s
created

MessageApi::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 1
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 $extraParams
25
     *
26
     * @return mixed
27
     */
28 2
    public function extractMeaning($text, Context $context = null, array $extraParams = [])
29
    {
30 2
        $query = array_merge($extraParams, [
31 2
            'q' => $text,
32 2
        ]);
33
34 2
        if (null !== $context) {
35 2
            $query['context'] = json_encode($context);
36 2
        }
37
38 2
        $response = $this->client->get('/message', $query);
39
40 2
        return $this->decodeResponse($response);
41
    }
42
}
43