Skip to content

Commit a2c33e2

Browse files
committed
Apply fixes from StyleCI
1 parent 2143ca2 commit a2c33e2

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

src/Models/Zones/Zone.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ public function changeProtection(bool $delete = true): ?APIResponse
192192

193193
public function exportZonefile(): ?APIResponse
194194
{
195-
$response = $this->httpClient->get('zones/' . $this->id . '/zonefile');
196-
if (!HetznerAPIClient::hasError($response)) {
195+
$response = $this->httpClient->get('zones/'.$this->id.'/zonefile');
196+
if (! HetznerAPIClient::hasError($response)) {
197197
return APIResponse::create([
198-
'zonefile' => json_decode((string)$response->getBody())->zonefile,
198+
'zonefile' => json_decode((string) $response->getBody())->zonefile,
199199
], $response->getHeaders());
200200
}
201201

@@ -204,14 +204,14 @@ public function exportZonefile(): ?APIResponse
204204

205205
public function changeTTL(int $ttl): ?APIResponse
206206
{
207-
$response = $this->httpClient->post('zones/' . $this->id . '/actions/change_ttl', [
207+
$response = $this->httpClient->post('zones/'.$this->id.'/actions/change_ttl', [
208208
'json' => [
209209
'ttl' => $ttl,
210210
],
211211
]);
212-
if (!HetznerAPIClient::hasError($response)) {
212+
if (! HetznerAPIClient::hasError($response)) {
213213
return APIResponse::create([
214-
'action' => Action::parse(json_decode((string)$response->getBody())->action),
214+
'action' => Action::parse(json_decode((string) $response->getBody())->action),
215215
], $response->getHeaders());
216216
}
217217

@@ -220,14 +220,14 @@ public function changeTTL(int $ttl): ?APIResponse
220220

221221
public function importZonefile(string $zonefile): ?APIResponse
222222
{
223-
$response = $this->httpClient->post('zones/' . $this->id . '/actions/import_zonefile', [
223+
$response = $this->httpClient->post('zones/'.$this->id.'/actions/import_zonefile', [
224224
'json' => [
225225
'zonefile' => $zonefile,
226226
],
227227
]);
228-
if (!HetznerAPIClient::hasError($response)) {
228+
if (! HetznerAPIClient::hasError($response)) {
229229
return APIResponse::create([
230-
'action' => Action::parse(json_decode((string)$response->getBody())->action),
230+
'action' => Action::parse(json_decode((string) $response->getBody())->action),
231231
], $response->getHeaders());
232232
}
233233

@@ -243,7 +243,6 @@ protected function replaceZoneIdInUri(string $uri): string
243243
return str_replace('{id}', $this->id, $uri);
244244
}
245245

246-
247246
/**
248247
* @param $input
249248
* @return \LKDev\HetznerCloud\Models\Zones\Zone|static |null
@@ -258,19 +257,19 @@ public static function parse($input)
258257
}
259258

260259
/**
261-
* @param array<PrimaryNameserver> $primary_nameservers
260+
* @param array<PrimaryNameserver> $primary_nameservers
262261
* @return void#
263262
*/
264263
public function changePrimaryNameservers(array $primary_nameservers)
265264
{
266-
$response = $this->httpClient->post('zones/' . $this->id . '/actions/change_primary_nameservers', [
265+
$response = $this->httpClient->post('zones/'.$this->id.'/actions/change_primary_nameservers', [
267266
'json' => [
268267
'primary_nameservers' => $primary_nameservers,
269268
],
270269
]);
271-
if (!HetznerAPIClient::hasError($response)) {
270+
if (! HetznerAPIClient::hasError($response)) {
272271
return APIResponse::create([
273-
'action' => Action::parse(json_decode((string)$response->getBody())->action),
272+
'action' => Action::parse(json_decode((string) $response->getBody())->action),
274273
], $response->getHeaders());
275274
}
276275

tests/Unit/Models/Zones/ZoneTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function setUp(): void
2020
parent::setUp();
2121
$tmp = new Zones($this->hetznerApi->getHttpClient());
2222

23-
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__ . '/fixtures/zone.json')));
23+
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__.'/fixtures/zone.json')));
2424
$this->zone = $tmp->getById(4711);
2525
}
2626

@@ -37,15 +37,15 @@ public function testDelete()
3737

3838
public function testUpdate()
3939
{
40-
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__ . '/fixtures/zone.json')));
40+
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__.'/fixtures/zone.json')));
4141
$this->zone->update(['name' => 'new-name']);
4242
$this->assertLastRequestEquals('PUT', '/zones/4711');
4343
$this->assertLastRequestBodyParametersEqual(['name' => 'new-name']);
4444
}
4545

4646
public function testChangeProtection()
4747
{
48-
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__ . '/fixtures/zone_action_change_protection.json')));
48+
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__.'/fixtures/zone_action_change_protection.json')));
4949
$apiResponse = $this->zone->changeProtection(true);
5050
$this->assertEquals('change_protection', $apiResponse->action->command);
5151
$this->assertEquals($this->zone->id, $apiResponse->action->resources[0]->id);
@@ -68,38 +68,37 @@ public function testChangeTTL()
6868
public function testImportZonefile()
6969
{
7070
$this->mockHandler->append(new Response(200, [], $this->getGenericActionResponse('import_zonefile')));
71-
$apiResponse = $this->zone->importZonefile("zonefile_content");
71+
$apiResponse = $this->zone->importZonefile('zonefile_content');
7272
$this->assertEquals('import_zonefile', $apiResponse->action->command);
7373
$this->assertEquals($this->zone->id, $apiResponse->action->resources[0]->id);
7474
$this->assertEquals('zone', $apiResponse->action->resources[0]->type);
7575
$this->assertLastRequestEquals('POST', '/zones/4711/actions/import_zonefile');
76-
$this->assertLastRequestBodyParametersEqual(['zonefile' => "zonefile_content"]);
76+
$this->assertLastRequestBodyParametersEqual(['zonefile' => 'zonefile_content']);
7777
}
7878

7979
public function testTestChangePrimaryNameservers()
8080
{
8181
$this->mockHandler->append(new Response(200, [], $this->getGenericActionResponse('import_zonefile')));
8282
$apiResponse = $this->zone->changePrimaryNameservers([
83-
new PrimaryNameserver("192.168.178.1", 53)
83+
new PrimaryNameserver('192.168.178.1', 53),
8484
]);
8585
$this->assertEquals('import_zonefile', $apiResponse->action->command);
8686
$this->assertEquals($this->zone->id, $apiResponse->action->resources[0]->id);
8787
$this->assertEquals('zone', $apiResponse->action->resources[0]->type);
8888
$this->assertLastRequestEquals('POST', '/zones/4711/actions/change_primary_nameservers');
89-
$this->assertLastRequestBodyParametersEqual(['primary_nameservers' => [["address" => "192.168.178.1", "port" => 53]]]);
89+
$this->assertLastRequestBodyParametersEqual(['primary_nameservers' => [['address' => '192.168.178.1', 'port' => 53]]]);
9090
}
9191

92-
9392
public function testExportZonefile()
9493
{
95-
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__ . '/fixtures/zone_zonefile.json')));
94+
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__.'/fixtures/zone_zonefile.json')));
9695
$apiResponse = $this->zone->exportZonefile();
9796
$this->assertNotEmpty($apiResponse->zonefile);
9897
$this->assertLastRequestEquals('GET', '/zones/4711/zonefile');
9998
}
10099

101100
protected function getGenericActionResponse(string $command)
102101
{
103-
return str_replace('$command', $command, file_get_contents(__DIR__ . '/fixtures/zone_action_generic.json'));
102+
return str_replace('$command', $command, file_get_contents(__DIR__.'/fixtures/zone_action_generic.json'));
104103
}
105104
}

0 commit comments

Comments
 (0)