ReviewOS

also looking at this

meemalabs/meema-client-php

Exceptions

#27
Merged glennmichael123 wants to merge exceptions into main
5 files +168 -14
src/Models/Favorite.phpmodified+17-0
Changes to src/Models/Favorite.php
@@ -3,6 +3,7 @@
33namespace Meema\MeemaApi\Models;
44
55use Meema\MeemaApi\Client;
6use Meema\MeemaApi\Exceptions\InvalidFormatException;
67use Meema\MeemaApi\Response\Response;
78
89class Favorite
@@ -50,6 +51,10 @@ class Favorite
5051 return $this->all();
5152 }
5253
54 if (! is_int($id)) {
55 throw new InvalidFormatException();
56 }
57
5358 $ids = is_array($id) ? $id : func_get_args();
5459
5560 return $this->client->request('GET', 'favorites', ['favorite_ids' => $ids]);
@@ -64,6 +69,10 @@ class Favorite
6469 */
6570 public function find($id)
6671 {
72 if (! is_int($id)) {
73 throw new InvalidFormatException();
74 }
75
6776 $response = $this->client->request('GET', "favorites/${id}");
6877
6978 return new Response($this, $response);
@@ -91,6 +100,10 @@ class Favorite
91100 */
92101 public function update($id, $data): array
93102 {
103 if (! is_int($id)) {
104 throw new InvalidFormatException();
105 }
106
94107 return $this->client->request('PATCH', "favorites/{$id}", $data);
95108 }
96109
@@ -103,6 +116,10 @@ class Favorite
103116 */
104117 public function delete($id)
105118 {
119 if (! is_int($id)) {
120 throw new InvalidFormatException();
121 }
122
106123 return $this->client->request('DELETE', "favorites/{$id}");
107124 }
108125}