Conditions | 6 |
Paths | 32 |
Total Lines | 30 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | public function analyze($text, array $params = null) |
||
26 | { |
||
27 | $headers = []; |
||
28 | |||
29 | $params['text'] = $text; |
||
30 | |||
31 | if (!isset($params['version'])) { |
||
32 | $params['version'] = \date('Y-m-d'); |
||
33 | } |
||
34 | |||
35 | if (!isset($params['sentences'])) { |
||
36 | $params['sentences'] = true; |
||
37 | } |
||
38 | |||
39 | if (isset($params['content_language'])) { |
||
40 | $headers['Content-Language'] = $params['content_language']; |
||
41 | } |
||
42 | |||
43 | if (isset($params['accept_language'])) { |
||
44 | $headers['Accept-Language'] = $params['accept_language']; |
||
45 | } |
||
46 | |||
47 | $response = $this->get('/api/v3/tone', $params, $headers); |
||
48 | |||
49 | if ($response->getStatusCode() !== 200) { |
||
50 | $this->handleErrors($response); |
||
51 | } |
||
52 | |||
53 | return $this->hydrator->hydrate($response, ToneAnalysis::class); |
||
54 | } |
||
55 | } |
||
56 |