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/Tag.phpmodified+18-13
Changes to src/Models/Tag.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 Tag
1011{
12 use CollectionsResponse;
13
1114 /**
1215 * @var \Meema\MeemaApi\Client
1316 */
@@ -38,7 +41,7 @@ class Tag
3841 *
3942 * @return array
4043 */
41 public function all(): array
44 public function all()
4245 {
4346 return $this->client->request('GET', 'tags');
4447 }
@@ -48,16 +51,16 @@ class Tag
4851 *
4952 * @param array $ids
5053 *
51 * @return array
54 * @return \Illuminate\Support\Collection|array
5255 */
53 public function get($ids = null): array
56 public function get($ids = null)
5457 {
5558 if ($this->model) {
56 return $this->fetchForModel();
59 return $this->toCollection($this->fetchForModel());
5760 }
5861
5962 if (! $ids) {
60 return $this->all();
63 return $this->toCollection($this->all());
6164 }
6265
6366 $ids = is_array($ids) ? $ids : func_get_args();
@@ -68,7 +71,9 @@ class Tag
6871 }
6972 }
7073
71 return $this->client->request('GET', 'tags', ['tag_ids' => $ids]);
74 $response = $this->client->request('GET', 'tags', ['tag_ids' => $ids]);
75
76 return $this->toCollection($response);
7277 }
7378
7479 /**
@@ -97,7 +102,7 @@ class Tag
97102 *
98103 * @return array
99104 */
100 public function update($id, $color): array
105 public function update($id, $color)
101106 {
102107 if (! is_int($id)) {
103108 throw new InvalidFormatException();
formatting only · 8 hidden lines
Changes to src/Models/Tag.php
@@ -150,7 +155,7 @@ class Tag formatting only
150155 return $this->associateToModel($tag);
151156 }
152157
153 /**
158 /**
154159 * Associate tags to media.
155160 *
156161 * @param array $tag
Changes to src/Models/Tag.php
@@ -197,7 +202,7 @@ class Tag
197202 *
198203 * @return array
199204 */
200 protected function fetchTagsForMedia($id): array
205 protected function fetchTagsForMedia($id)
201206 {
202207 return $this->client->request('GET', "media/{$id}/tags");
203208 }
@@ -209,7 +214,7 @@ class Tag
209214 *
210215 * @return array
211216 */
212 protected function fetchTagsForFolder($id): array
217 protected function fetchTagsForFolder($id)
213218 {
214219 return $this->client->request('GET', "folders/{$id}/tags");
215220 }
@@ -257,7 +262,7 @@ class Tag
257262 *
258263 * @return array
259264 */
260 protected function fetchForModel(): array
265 protected function fetchForModel()
261266 {
262267 $data = [];
263268
@@ -282,7 +287,7 @@ class Tag
282287 *
283288 * @return array
284289 */
285 protected function associateToModel($tag): array
290 protected function associateToModel($tag)
286291 {
287292 $data = [];
288293
@@ -307,7 +312,7 @@ class Tag
307312 *
308313 * @return array
309314 */
310 protected function disassociateToModel($tag): array
315 protected function disassociateToModel($tag)
311316 {
312317 $data = [];
313318