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 Tag |
| @@ -59,6 +60,10 @@ class Tag | ||
| 59 | 60 | return $this->all(); |
| 60 | 61 | } |
| 61 | 62 | |
| 63 | if (! is_int($id)) { | |
| 64 | throw new InvalidFormatException(); | |
| 65 | } | |
| 66 | ||
| 62 | 67 | $ids = is_array($id) ? $id : func_get_args(); |
| 63 | 68 | |
| 64 | 69 | return $this->client->request('GET', 'tags', ['tag_ids' => $ids]); |
| @@ -73,6 +78,10 @@ class Tag | ||
| 73 | 78 | */ |
| 74 | 79 | public function find($id): Response |
| 75 | 80 | { |
| 81 | if (! is_int($id)) { | |
| 82 | throw new InvalidFormatException(); | |
| 83 | } | |
| 84 | ||
| 76 | 85 | $response = $this->client->request('GET', "tags/${id}"); |
| 77 | 86 | |
| 78 | 87 | return new Response($this, $response); |
| @@ -102,6 +111,10 @@ class Tag | ||
| 102 | 111 | */ |
| 103 | 112 | public function update($id, $data): array |
| 104 | 113 | { |
| 114 | if (! is_int($id)) { | |
| 115 | throw new InvalidFormatException(); | |
| 116 | } | |
| 117 | ||
| 105 | 118 | return $this->client->request('PATCH', 'tags/color', $data); |
| 106 | 119 | } |
| 107 | 120 | |
| @@ -114,6 +127,10 @@ class Tag | ||
| 114 | 127 | */ |
| 115 | 128 | public function delete($id) |
| 116 | 129 | { |
| 130 | if (! is_int($id)) { | |
| 131 | throw new InvalidFormatException(); | |
| 132 | } | |
| 133 | ||
| 117 | 134 | return $this->client->request('DELETE', "tags/{$id}"); |
| 118 | 135 | } |
| 119 | 136 | |