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