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

MessageApi   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 36
rs 10
ccs 12
cts 12
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A extractMeaning() 0 14 2
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