| @@ 226-237 (lines=12) @@ | ||
| 223 | : []; |
|
| 224 | $api_data = json_decode($response->getBody(), TRUE); |
|
| 225 | ||
| 226 | if ($api_data === $cached && file_exists($transformed_cache_file)) |
|
| 227 | { |
|
| 228 | return json_decode(file_get_contents($transformed_cache_file), TRUE); |
|
| 229 | } |
|
| 230 | else |
|
| 231 | { |
|
| 232 | file_put_contents($cache_file, json_encode($api_data)); |
|
| 233 | $transformer = new AnimeListTransformer(); |
|
| 234 | $transformed = $transformer->transform_collection($api_data); |
|
| 235 | file_put_contents($transformed_cache_file, json_encode($transformed)); |
|
| 236 | return $transformed; |
|
| 237 | } |
|
| 238 | } |
|
| 239 | } |
|
| 240 | // End of AnimeModel.php |
|
| @@ 163-176 (lines=14) @@ | ||
| 160 | ? json_decode(file_get_contents($cache_file), TRUE) |
|
| 161 | : []; |
|
| 162 | ||
| 163 | if ($cached_data === $api_data && file_exists($transformed_cache_file)) |
|
| 164 | { |
|
| 165 | return json_decode(file_get_contents($transformed_cache_file), TRUE); |
|
| 166 | } |
|
| 167 | else |
|
| 168 | { |
|
| 169 | file_put_contents($cache_file, json_encode($api_data)); |
|
| 170 | ||
| 171 | $zippered_data = $this->zipper_lists($api_data); |
|
| 172 | $transformer = new Transformer\MangaListTransformer(); |
|
| 173 | $transformed_data = $transformer->transform_collection($zippered_data); |
|
| 174 | file_put_contents($transformed_cache_file, json_encode($transformed_data)); |
|
| 175 | return $transformed_data; |
|
| 176 | } |
|
| 177 | } |
|
| 178 | ||
| 179 | /** |
|