| Conditions | 5 |
| Paths | 16 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function classify($image, $params = []) |
||
|
|
|||
| 22 | { |
||
| 23 | if (filter_var($image, FILTER_VALIDATE_URL)) { |
||
| 24 | $response = $this->classifyUrl($image, $params); |
||
| 25 | } |
||
| 26 | |||
| 27 | if (file_exists($image)) { |
||
| 28 | $image = fopen($image, 'r'); |
||
| 29 | } |
||
| 30 | |||
| 31 | if (is_resource($image)) { |
||
| 32 | $params[] = [ |
||
| 33 | 'name' => 'images_file', |
||
| 34 | 'content' => $image |
||
| 35 | ]; |
||
| 36 | |||
| 37 | $response = $this->postRaw('/v3/classify', $params); |
||
| 38 | } |
||
| 39 | |||
| 40 | if ($response->getStatusCode() !== 200) { |
||
| 41 | $this->handleErrors($response); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $this->hydrator->hydrate($response, ClassifiedImages::class); |
||
| 45 | } |
||
| 46 | |||
| 71 |