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