Completed
Push — develop ( 5fc40e...dcac96 )
by Adam
13s
created

ToneChat   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 27
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A analyze() 0 16 3
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer\Api;
4
5
use IBM\Watson\Common\Api\AbstractApi;
6
use IBM\Watson\ToneAnalyzer\Model\UtteranceAnalyses;
7
8
class ToneChat extends AbstractApi
9
{
10
    /**
11
     * Analyze tone chat
12
     *
13
     * @param string    $text
14
     * @param array     $params
15
     *
16
     * @return mixed
17
     */
18 6
    public function analyze($text, array $params = [])
19
    {
20 6
        $headers = ['Content-Type' => 'application/json'];
21
22 6
        if (!isset($params['version'])) {
23 6
            $params['version'] = \date('Y-m-d');
24 2
        }
25
26 6
        $response = $this->postRaw('/api/v3/tone_chat' . '?' . http_build_query($params), $text, $headers);
27
28 6
        if ($response->getStatusCode() !== 200) {
29 3
            $this->handleErrors($response);
30
        }
31
32 3
        return $this->hydrator->hydrate($response, UtteranceAnalyses::class);
33
    }
34
}
35