| Conditions | 6 |
| Paths | 6 |
| Total Lines | 41 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php namespace Onigoetz\Imagecache\Support\Raw; |
||
| 10 | public static function run($config, $request) |
||
| 11 | { |
||
| 12 | $imagecache = new Manager($config); |
||
| 13 | |||
| 14 | try { |
||
| 15 | $final_file = $imagecache->handleRequest($request['preset'], $request['file']); |
||
| 16 | } catch (InvalidPresetException $e) { |
||
| 17 | header('HTTP/1.0 404 Not Found'); |
||
| 18 | echo $e->getMessage(); |
||
| 19 | |||
| 20 | return; |
||
| 21 | } catch (NotFoundException $e) { |
||
| 22 | header('HTTP/1.0 404 Not Found'); |
||
| 23 | echo $e->getMessage(); |
||
| 24 | |||
| 25 | return; |
||
| 26 | } catch (\RuntimeException $e) { |
||
| 27 | header('HTTP/1.0 500 Internal Server Error'); |
||
| 28 | echo $e->getMessage(); |
||
| 29 | |||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | $transfer = new Transfer($final_file); |
||
| 34 | |||
| 35 | // if the status is 304, we don't |
||
| 36 | // need to send the content with it |
||
| 37 | if ($transfer->getStatus() == 304) { |
||
| 38 | header('HTTP/1.1 304 Not Modified'); |
||
| 39 | |||
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | header('HTTP/1.1 200 OK'); |
||
| 44 | |||
| 45 | foreach ($transfer->getFormattedHeaders() as $header) { |
||
| 46 | header($header); |
||
| 47 | } |
||
| 48 | |||
| 49 | $transfer->stream(); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |