1111use LKDev \HetznerCloud \Models \Meta ;
1212use LKDev \HetznerCloud \Models \Model ;
1313use LKDev \HetznerCloud \Models \Protection ;
14- use LKDev \HetznerCloud \RequestOpts ;
1514
1615class Zone extends Model implements Resource
1716{
@@ -75,8 +74,8 @@ class Zone extends Model implements Resource
7574 public AuthoritativeNameservers $ authoritative_nameservers ;
7675
7776 /**
78- * @param int $zoneId
79- * @param GuzzleClient|null $httpClient
77+ * @param int $zoneId
78+ * @param GuzzleClient|null $httpClient
8079 */
8180 public function __construct (int $ zoneId , ?GuzzleClient $ httpClient = null )
8281 {
@@ -134,9 +133,9 @@ public function reload()
134133 public function delete (): ?APIResponse
135134 {
136135 $ response = $ this ->httpClient ->delete ($ this ->replaceZoneIdInUri ('zones/{id} ' ));
137- if (!HetznerAPIClient::hasError ($ response )) {
136+ if (! HetznerAPIClient::hasError ($ response )) {
138137 return APIResponse::create ([
139- 'action ' => Action::parse (json_decode ((string )$ response ->getBody ())->action ),
138+ 'action ' => Action::parse (json_decode ((string ) $ response ->getBody ())->action ),
140139 ], $ response ->getHeaders ());
141140 }
142141
@@ -148,7 +147,7 @@ public function delete(): ?APIResponse
148147 *
149148 * @see https://docs.hetzner.cloud/reference/cloud#zones-update-a-zone
150149 *
151- * @param array $data
150+ * @param array $data
152151 * @return APIResponse|null
153152 *
154153 * @throws \LKDev\HetznerCloud\APIException
@@ -158,9 +157,9 @@ public function update(array $data)
158157 $ response = $ this ->httpClient ->put ($ this ->replaceZoneIdInUri ('zones/{id} ' ), [
159158 'json ' => $ data ,
160159 ]);
161- if (!HetznerAPIClient::hasError ($ response )) {
160+ if (! HetznerAPIClient::hasError ($ response )) {
162161 return APIResponse::create ([
163- 'zone ' => self ::parse (json_decode ((string )$ response ->getBody ())->zone ),
162+ 'zone ' => self ::parse (json_decode ((string ) $ response ->getBody ())->zone ),
164163 ], $ response ->getHeaders ());
165164 }
166165
@@ -172,21 +171,21 @@ public function update(array $data)
172171 *
173172 * @see https://docs.hetzner.cloud/#zone-actions-change-zone-protection
174173 *
175- * @param bool $delete
174+ * @param bool $delete
176175 * @return APIResponse|null
177176 *
178177 * @throws \LKDev\HetznerCloud\APIException
179178 */
180179 public function changeProtection (bool $ delete = true ): ?APIResponse
181180 {
182- $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/change_protection ' , [
181+ $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/change_protection ' , [
183182 'json ' => [
184183 'delete ' => $ delete ,
185184 ],
186185 ]);
187- if (!HetznerAPIClient::hasError ($ response )) {
186+ if (! HetznerAPIClient::hasError ($ response )) {
188187 return APIResponse::create ([
189- 'action ' => Action::parse (json_decode ((string )$ response ->getBody ())->action ),
188+ 'action ' => Action::parse (json_decode ((string ) $ response ->getBody ())->action ),
190189 ], $ response ->getHeaders ());
191190 }
192191
@@ -195,10 +194,10 @@ public function changeProtection(bool $delete = true): ?APIResponse
195194
196195 public function exportZonefile (): ?APIResponse
197196 {
198- $ response = $ this ->httpClient ->get ('zones/ ' . $ this ->id . '/zonefile ' );
199- if (!HetznerAPIClient::hasError ($ response )) {
197+ $ response = $ this ->httpClient ->get ('zones/ ' . $ this ->id . '/zonefile ' );
198+ if (! HetznerAPIClient::hasError ($ response )) {
200199 return APIResponse::create ([
201- 'zonefile ' => json_decode ((string )$ response ->getBody ())->zonefile ,
200+ 'zonefile ' => json_decode ((string ) $ response ->getBody ())->zonefile ,
202201 ], $ response ->getHeaders ());
203202 }
204203
@@ -207,14 +206,14 @@ public function exportZonefile(): ?APIResponse
207206
208207 public function changeTTL (int $ ttl ): ?APIResponse
209208 {
210- $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/change_ttl ' , [
209+ $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/change_ttl ' , [
211210 'json ' => [
212211 'ttl ' => $ ttl ,
213212 ],
214213 ]);
215- if (!HetznerAPIClient::hasError ($ response )) {
214+ if (! HetznerAPIClient::hasError ($ response )) {
216215 return APIResponse::create ([
217- 'action ' => Action::parse (json_decode ((string )$ response ->getBody ())->action ),
216+ 'action ' => Action::parse (json_decode ((string ) $ response ->getBody ())->action ),
218217 ], $ response ->getHeaders ());
219218 }
220219
@@ -223,22 +222,22 @@ public function changeTTL(int $ttl): ?APIResponse
223222
224223 public function importZonefile (string $ zonefile ): ?APIResponse
225224 {
226- $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/import_zonefile ' , [
225+ $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/import_zonefile ' , [
227226 'json ' => [
228227 'zonefile ' => $ zonefile ,
229228 ],
230229 ]);
231- if (!HetznerAPIClient::hasError ($ response )) {
230+ if (! HetznerAPIClient::hasError ($ response )) {
232231 return APIResponse::create ([
233- 'action ' => Action::parse (json_decode ((string )$ response ->getBody ())->action ),
232+ 'action ' => Action::parse (json_decode ((string ) $ response ->getBody ())->action ),
234233 ], $ response ->getHeaders ());
235234 }
236235
237236 return null ;
238237 }
239238
240239 /**
241- * @param string $uri
240+ * @param string $uri
242241 * @return string
243242 */
244243 protected function replaceZoneIdInUri (string $ uri ): string
@@ -260,29 +259,31 @@ public static function parse($input)
260259 }
261260
262261 /**
263- * @param array<PrimaryNameserver> $primary_nameservers
262+ * @param array<PrimaryNameserver> $primary_nameservers
264263 * @return void#
264+ *
265265 * @throws APIException
266266 */
267267 public function changePrimaryNameservers (array $ primary_nameservers )
268268 {
269- $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/change_primary_nameservers ' , [
269+ $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/actions/change_primary_nameservers ' , [
270270 'json ' => [
271271 'primary_nameservers ' => $ primary_nameservers ,
272272 ],
273273 ]);
274- if (!HetznerAPIClient::hasError ($ response )) {
274+ if (! HetznerAPIClient::hasError ($ response )) {
275275 return APIResponse::create ([
276- 'action ' => Action::parse (json_decode ((string )$ response ->getBody ())->action ),
276+ 'action ' => Action::parse (json_decode ((string ) $ response ->getBody ())->action ),
277277 ], $ response ->getHeaders ());
278278 }
279279
280280 return null ;
281281 }
282282
283283 /**
284- * @param RRSetRequestOpts|null $requestOpts
284+ * @param RRSetRequestOpts|null $requestOpts
285285 * @return array<RRSet>
286+ *
286287 * @throws APIException
287288 */
288289 public function allRRSets (?RRSetRequestOpts $ requestOpts = null ): array
@@ -306,22 +307,24 @@ public function allRRSets(?RRSetRequestOpts $requestOpts = null): array
306307 }
307308
308309 /**
309- * @param RRSetRequestOpts|null $requestOpts
310+ * @param RRSetRequestOpts|null $requestOpts
310311 * @return APIResponse|null
312+ *
311313 * @throws \LKDev\HetznerCloud\APIException
312314 */
313315 public function listRRSets (?RRSetRequestOpts $ requestOpts = null ): ?APIResponse
314316 {
315317 if ($ requestOpts == null ) {
316318 $ requestOpts = new RRSetRequestOpts ();
317319 }
318- $ response = $ this ->httpClient ->get ('zones/ ' . $ this ->id . " /rrsets " . $ requestOpts ->buildQuery ());
319- if (!HetznerAPIClient::hasError ($ response )) {
320- $ resp = json_decode ((string )$ response ->getBody ());
320+ $ response = $ this ->httpClient ->get ('zones/ ' . $ this ->id . ' /rrsets ' . $ requestOpts ->buildQuery ());
321+ if (! HetznerAPIClient::hasError ($ response )) {
322+ $ resp = json_decode ((string ) $ response ->getBody ());
321323 $ rrsets = [];
322324 foreach ($ resp ->rrsets as $ rrset ) {
323325 $ rrsets [] = RRSet::fromResponse (get_object_vars ($ rrset ));
324326 }
327+
325328 return APIResponse::create ([
326329 'meta ' => Meta::parse ($ resp ->meta ),
327330 'rrsets ' => $ rrsets ,
@@ -332,12 +335,13 @@ public function listRRSets(?RRSetRequestOpts $requestOpts = null): ?APIResponse
332335 }
333336
334337 /**
335- * @param string $name
336- * @param string $type
337- * @param array<Record> $records
338- * @param int|null $ttl
339- * @param array|null $labels
338+ * @param string $name
339+ * @param string $type
340+ * @param array<Record> $records
341+ * @param int|null $ttl
342+ * @param array|null $labels
340343 * @return void
344+ *
341345 * @throws APIException
342346 */
343347 public function createRRSet (string $ name , string $ type , array $ records , ?int $ ttl = null , ?array $ labels = [])
@@ -350,16 +354,16 @@ public function createRRSet(string $name, string $type, array $records, ?int $tt
350354 if ($ ttl !== null ) {
351355 $ parameters ['ttl ' ] = $ ttl ;
352356 }
353- if (!empty ($ labels )) {
357+ if (! empty ($ labels )) {
354358 $ parameters ['labels ' ] = $ labels ;
355359 }
356360
357- $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/rrsets ' , [
361+ $ response = $ this ->httpClient ->post ('zones/ ' . $ this ->id . '/rrsets ' , [
358362 'json ' => $ parameters ,
359363 ]);
360364
361- if (!HetznerAPIClient::hasError ($ response )) {
362- $ payload = json_decode ((string )$ response ->getBody ());
365+ if (! HetznerAPIClient::hasError ($ response )) {
366+ $ payload = json_decode ((string ) $ response ->getBody ());
363367
364368 return APIResponse::create ([
365369 'action ' => Action::parse ($ payload ->action ),
0 commit comments