| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 7 | public function detect($response) |
|
| 25 | { |
||
| 26 | 7 | if (stripos($response, '<error>') === false) { |
|
| 27 | 1 | return $response; |
|
| 28 | } |
||
| 29 | |||
| 30 | 6 | $error = preg_replace('/^.*<error>([^<]+)<\/error>.*$/ims', '$1', $response); |
|
| 31 | |||
| 32 | switch ($error) { |
||
| 33 | 6 | case 'Banned': |
|
| 34 | 2 | throw BannedException::banned(); |
|
| 35 | 4 | case 'Anime not found': |
|
| 36 | 2 | throw NotFoundException::anime(); |
|
| 37 | default: |
||
| 38 | 2 | throw ErrorException::error($error); |
|
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 |