ReviewOS

also looking at this

meemalabs/meema-client-php

Collection response

#52
Merged glennmichael123 wants to merge collection-response into main
11 files +3638 -3582
src/Models/Favorite.phpmodified+10-5
Changes to src/Models/Favorite.php
@@ -5,9 +5,12 @@ namespace Meema\MeemaApi\Models;
55use Meema\MeemaApi\Client;
66use Meema\MeemaApi\Exceptions\InvalidFormatException;
77use Meema\MeemaApi\Response\Response;
8use Meema\MeemaApi\Traits\CollectionsResponse;
89
910class Favorite
1011{
12 use CollectionsResponse;
13
1114 /**
1215 * @var Meema\MeemaApi\Client
1316 */
@@ -33,7 +36,7 @@ class Favorite
3336 *
3437 * @return array
3538 */
36 public function all(): array
39 public function all()
3740 {
3841 return $this->client->request('GET', 'favorites');
3942 }
@@ -43,12 +46,12 @@ class Favorite
4346 *
4447 * @param array $ids
4548 *
46 * @return array
49 * @return \Illuminate\Support\Collection|array
4750 */
4851 public function get($ids = null)
4952 {
5053 if (! $ids) {
51 return $this->all();
54 return $this->toCollection($this->all());
5255 }
5356
5457 $ids = is_array($ids) ? $ids : func_get_args();
@@ -59,7 +62,9 @@ class Favorite
5962 }
6063 }
6164
62 return $this->client->request('GET', 'favorites', ['favorite_ids' => $ids]);
65 $response = $this->client->request('GET', 'favorites', ['favorite_ids' => $ids]);
66
67 return $this->toCollection($response);
6368 }
6469
6570 /**
@@ -100,7 +105,7 @@ class Favorite
100105 *
101106 * @return array
102107 */
103 public function update($id, $data): array
108 public function update($id, $data)
104109 {
105110 if (! is_int($id)) {
106111 throw new InvalidFormatException();