| Total Complexity | 4 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 70% |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class XKCDService extends BaseService implements XKCDServiceInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * fetches the url from the specified URL |
||
| 23 | * |
||
| 24 | * @param $url |
||
| 25 | * @return XKCDJson |
||
| 26 | * @throws ServerException |
||
| 27 | */ |
||
| 28 | 4 | protected function getComicFromUrl($url) |
|
| 29 | { |
||
| 30 | try { |
||
| 31 | 4 | $newestJson = file_get_contents($url); |
|
| 32 | 4 | return json_decode($newestJson); |
|
| 33 | } catch (Exception $ex) { |
||
| 34 | $this->getLoggingService()->log("failed to fetch comic from xkcd: " . $ex); |
||
| 35 | throw new ServerException(ServerError::CONNECTION_FAILED); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * returns the newest XKCD comic |
||
| 41 | * |
||
| 42 | * @param $number |
||
| 43 | * @return XKCDJson |
||
| 44 | * @throws ServerException |
||
| 45 | */ |
||
| 46 | 3 | public function getComic($number) |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * returns the XKCD comic with the specified number |
||
| 53 | * |
||
| 54 | * @return XKCDJson |
||
| 55 | * @throws ServerException |
||
| 56 | */ |
||
| 57 | 4 | public function getNewestComic() |
|
| 60 | } |
||
| 61 | } |