also looking at this
Exceptions
#27
5 files
+168
-14
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | namespace Meema\MeemaApi\Models; |
| 4 | 4 | |
| 5 | 5 | use Meema\MeemaApi\Client; |
| 6 | use Meema\MeemaApi\Exceptions\InvalidFormatException; | |
| 6 | 7 | use Meema\MeemaApi\Response\Response; |
| 7 | 8 | |
| 8 | 9 | class Favorite |
| @@ -50,6 +51,10 @@ class Favorite | ||
| 50 | 51 | return $this->all(); |
| 51 | 52 | } |
| 52 | 53 | |
| 54 | if (! is_int($id)) { | |
| 55 | throw new InvalidFormatException(); | |
| 56 | } | |
| 57 | ||
| 53 | 58 | $ids = is_array($id) ? $id : func_get_args(); |
| 54 | 59 | |
| 55 | 60 | return $this->client->request('GET', 'favorites', ['favorite_ids' => $ids]); |
| @@ -64,6 +69,10 @@ class Favorite | ||
| 64 | 69 | */ |
| 65 | 70 | public function find($id) |
| 66 | 71 | { |
| 72 | if (! is_int($id)) { | |
| 73 | throw new InvalidFormatException(); | |
| 74 | } | |
| 75 | ||
| 67 | 76 | $response = $this->client->request('GET', "favorites/${id}"); |
| 68 | 77 | |
| 69 | 78 | return new Response($this, $response); |
| @@ -91,6 +100,10 @@ class Favorite | ||
| 91 | 100 | */ |
| 92 | 101 | public function update($id, $data): array |
| 93 | 102 | { |
| 103 | if (! is_int($id)) { | |
| 104 | throw new InvalidFormatException(); | |
| 105 | } | |
| 106 | ||
| 94 | 107 | return $this->client->request('PATCH', "favorites/{$id}", $data); |
| 95 | 108 | } |
| 96 | 109 | |
| @@ -103,6 +116,10 @@ class Favorite | ||
| 103 | 116 | */ |
| 104 | 117 | public function delete($id) |
| 105 | 118 | { |
| 119 | if (! is_int($id)) { | |
| 120 | throw new InvalidFormatException(); | |
| 121 | } | |
| 122 | ||
| 106 | 123 | return $this->client->request('DELETE', "favorites/{$id}"); |
| 107 | 124 | } |
| 108 | 125 | } |