| Conditions | 3 |
| Paths | 3 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function retrieve( |
||
| 28 | CachableArtItemInterface $item, |
||
| 29 | ): array { |
||
| 30 | $artItemId = $item->getArtItemId(); |
||
| 31 | |||
| 32 | if ($artItemId === null) { |
||
| 33 | throw new Exception\ArtContentException('item does not provide art'); |
||
| 34 | } |
||
| 35 | $path = sprintf( |
||
| 36 | '%s/img/%s/%s.jpg', |
||
| 37 | $this->config->getAssetPath(), |
||
| 38 | $item->getArtItemType(), |
||
| 39 | $artItemId |
||
| 40 | ); |
||
| 41 | |||
| 42 | // @todo support other mimetypes |
||
| 43 | $mimeType = 'image/jpg'; |
||
| 44 | |||
| 45 | if (!file_exists($path)) { |
||
| 46 | throw new Exception\ArtContentException( |
||
| 47 | sprintf('File `%s` not found', $path) |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | |||
| 51 | return [ |
||
| 52 | 'mimeType' => $mimeType, |
||
| 53 | 'content' => (string) file_get_contents($path), |
||
| 54 | ]; |
||
| 57 |