MessageApi   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

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