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/Tag.phpmodified+17-0
Changes to src/Models/Tag.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 Tag
@@ -59,6 +60,10 @@ class Tag
5960 return $this->all();
6061 }
6162
63 if (! is_int($id)) {
64 throw new InvalidFormatException();
65 }
66
6267 $ids = is_array($id) ? $id : func_get_args();
6368
6469 return $this->client->request('GET', 'tags', ['tag_ids' => $ids]);
@@ -73,6 +78,10 @@ class Tag
7378 */
7479 public function find($id): Response
7580 {
81 if (! is_int($id)) {
82 throw new InvalidFormatException();
83 }
84
7685 $response = $this->client->request('GET', "tags/${id}");
7786
7887 return new Response($this, $response);
@@ -102,6 +111,10 @@ class Tag
102111 */
103112 public function update($id, $data): array
104113 {
114 if (! is_int($id)) {
115 throw new InvalidFormatException();
116 }
117
105118 return $this->client->request('PATCH', 'tags/color', $data);
106119 }
107120
@@ -114,6 +127,10 @@ class Tag
114127 */
115128 public function delete($id)
116129 {
130 if (! is_int($id)) {
131 throw new InvalidFormatException();
132 }
133
117134 return $this->client->request('DELETE', "tags/{$id}");
118135 }
119136