Skip to content

Commit 7b7b8c7

Browse files
committed
Apply fixes from StyleCI
1 parent 99ed071 commit 7b7b8c7

File tree

10 files changed

+96
-110
lines changed

10 files changed

+96
-110
lines changed

src/HetznerAPIClient.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class HetznerAPIClient
6464
protected GuzzleClient $httpClient;
6565

6666
/**
67-
* @param string $apiToken
68-
* @param string $baseUrl
69-
* @param string $userAgent
67+
* @param string $apiToken
68+
* @param string $baseUrl
69+
* @param string $userAgent
7070
*/
7171
public function __construct(string $apiToken, $baseUrl = 'https://api.hetzner.cloud/v1/', $userAgent = '')
7272
{
@@ -102,7 +102,7 @@ public function getBaseUrl(): string
102102
}
103103

104104
/**
105-
* @param string $userAgent
105+
* @param string $userAgent
106106
* @return HetznerAPIClient
107107
*/
108108
public function setUserAgent(string $userAgent): self
@@ -113,7 +113,7 @@ public function setUserAgent(string $userAgent): self
113113
}
114114

115115
/**
116-
* @param string $baseUrl
116+
* @param string $baseUrl
117117
* @return HetznerAPIClient
118118
*/
119119
public function setBaseUrl(string $baseUrl): self
@@ -142,13 +142,13 @@ public function setHttpClient(GuzzleClient $client): self
142142
}
143143

144144
/**
145-
* @param \Psr\Http\Message\ResponseInterface $response
145+
* @param \Psr\Http\Message\ResponseInterface $response
146146
*
147147
* @throws \LKDev\HetznerCloud\APIException
148148
*/
149149
public static function throwError(ResponseInterface $response)
150150
{
151-
$body = (string)$response->getBody();
151+
$body = (string) $response->getBody();
152152
if (strlen($body) > 0) {
153153
$error = \GuzzleHttp\json_decode($body);
154154
throw new APIException(APIResponse::create([
@@ -161,15 +161,15 @@ public static function throwError(ResponseInterface $response)
161161
}
162162

163163
/**
164-
* @param \Psr\Http\Message\ResponseInterface $response
164+
* @param \Psr\Http\Message\ResponseInterface $response
165165
* @return bool
166166
*
167167
* @throws \LKDev\HetznerCloud\APIException
168168
*/
169169
public static function hasError(ResponseInterface $response)
170170
{
171-
$responseDecoded = json_decode((string)$response->getBody());
172-
if (strlen((string)$response->getBody()) > 0) {
171+
$responseDecoded = json_decode((string) $response->getBody());
172+
if (strlen((string) $response->getBody()) > 0) {
173173
if (property_exists($responseDecoded, 'error')) {
174174
self::throwError($response);
175175

@@ -328,7 +328,6 @@ public function loadBalancerTypes()
328328
return new LoadBalancerTypes($this->httpClient);
329329
}
330330

331-
332331
public function zones()
333332
{
334333
return new Zones($this->httpClient);

src/Models/Zones/AuthoritativeNameservers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class AuthoritativeNameservers
1010
public string $delegation_status;
1111

1212
/**
13-
* @param array $assigned
14-
* @param array $delegated
15-
* @param string $delegation_last_check
16-
* @param string $delegation_status
13+
* @param array $assigned
14+
* @param array $delegated
15+
* @param string $delegation_last_check
16+
* @param string $delegation_status
1717
*/
1818
public function __construct(array $assigned, array $delegated, string $delegation_last_check, string $delegation_status)
1919
{

src/Models/Zones/PrimaryNameserver.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ class PrimaryNameserver
88
public int $port;
99

1010
/**
11-
* @param string $address
12-
* @param int $port
11+
* @param string $address
12+
* @param int $port
1313
*/
1414
public function __construct(string $address, int $port)
1515
{
1616
$this->port = $port;
1717
$this->address = $address;
1818
}
1919

20-
2120
public static function fromResponse(array $response): PrimaryNameserver
2221
{
2322
return new self($response['address'], $response['port']);

src/Models/Zones/RRSet.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace LKDev\HetznerCloud\Models\Zones;
44

5-
use LKDev\HetznerCloud\Models\Protection;
6-
75
class RRSet
86
{
97
public string $id;
@@ -15,13 +13,13 @@ class RRSet
1513
public RRSetProtection $protection;
1614

1715
/**
18-
* @param string $id
19-
* @param string $name
20-
* @param string $type
21-
* @param int $ttl
22-
* @param array $records
23-
* @param array|null $labels
24-
* @param RRSetProtection|null $protection
16+
* @param string $id
17+
* @param string $name
18+
* @param string $type
19+
* @param int $ttl
20+
* @param array $records
21+
* @param array|null $labels
22+
* @param RRSetProtection|null $protection
2523
*/
2624
public function __construct(string $id, string $name, string $type, int $ttl, array $records, ?array $labels, ?RRSetProtection $protection)
2725
{
@@ -42,25 +40,24 @@ public static function fromResponse(array $data): RRSet
4240
public function __toRequest(): array
4341
{
4442
$r = [
45-
"name" => $this->name,
43+
'name' => $this->name,
4644
'type' => $this->type,
4745
'ttl' => $this->ttl,
4846
'records' => $this->records,
4947
];
50-
if (!empty($this->labels)) {
48+
if (! empty($this->labels)) {
5149
$r['labels'] = $this->labels;
5250
}
51+
5352
return $r;
5453
}
5554
}
5655

57-
5856
class Record
5957
{
6058
public string $value;
6159
public string $comment;
6260

63-
6461
public function __construct(string $value, string $comment)
6562
{
6663
$this->value = $value;

src/Models/Zones/RRSetProtection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ class RRSetProtection extends Model
1919
*/
2020
public $change;
2121

22-
2322
/**
2423
* Protection constructor.
2524
*
26-
* @param bool $delete
25+
* @param bool $delete
2726
*/
2827
public function __construct(bool $delete)
2928
{
@@ -33,17 +32,18 @@ public function __construct(bool $delete)
3332
}
3433

3534
/**
36-
* @param array $input
35+
* @param array $input
3736
* @return ?RRSetProtection
3837
*/
3938
public static function parse($input)
4039
{
4140
if ($input == null) {
4241
return null;
4342
}
44-
if (!is_array($input)) {
43+
if (! is_array($input)) {
4544
return null;
4645
}
46+
4747
return new self($input['change'] ?? false);
4848
}
4949
}

src/Models/Zones/Zone.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ class Zone extends Model implements Resource
3838
public string $mode;
3939
/**
4040
* @var array<PrimaryNameserver>
41-
*
4241
*/
4342
public array $primary_nameservers;
4443

45-
4644
/**
4745
* @var array|\LKDev\HetznerCloud\Models\Protection
4846
*/
@@ -65,7 +63,6 @@ class Zone extends Model implements Resource
6563

6664
/**
6765
* @var string
68-
*
6966
*/
7067
public string $registrar;
7168

@@ -75,8 +72,8 @@ class Zone extends Model implements Resource
7572
public AuthoritativeNameservers $authoritative_nameservers;
7673

7774
/**
78-
* @param int $zoneId
79-
* @param GuzzleClient|null $httpClient
75+
* @param int $zoneId
76+
* @param GuzzleClient|null $httpClient
8077
*/
8178
public function __construct(int $zoneId, ?GuzzleClient $httpClient = null)
8279
{
@@ -134,9 +131,9 @@ public function reload()
134131
public function delete(): ?APIResponse
135132
{
136133
$response = $this->httpClient->delete($this->replaceZoneIdInUri('zones/{id}'));
137-
if (!HetznerAPIClient::hasError($response)) {
134+
if (! HetznerAPIClient::hasError($response)) {
138135
return APIResponse::create([
139-
'action' => Action::parse(json_decode((string)$response->getBody())->action),
136+
'action' => Action::parse(json_decode((string) $response->getBody())->action),
140137
], $response->getHeaders());
141138
}
142139

@@ -148,7 +145,7 @@ public function delete(): ?APIResponse
148145
*
149146
* @see https://docs.hetzner.cloud/reference/cloud#zones-update-a-zone
150147
*
151-
* @param array $data
148+
* @param array $data
152149
* @return APIResponse|null
153150
*
154151
* @throws \LKDev\HetznerCloud\APIException
@@ -158,9 +155,9 @@ public function update(array $data)
158155
$response = $this->httpClient->put($this->replaceZoneIdInUri('zones/{id}'), [
159156
'json' => $data,
160157
]);
161-
if (!HetznerAPIClient::hasError($response)) {
158+
if (! HetznerAPIClient::hasError($response)) {
162159
return APIResponse::create([
163-
'zone' => self::parse(json_decode((string)$response->getBody())->zone),
160+
'zone' => self::parse(json_decode((string) $response->getBody())->zone),
164161
], $response->getHeaders());
165162
}
166163

@@ -172,29 +169,29 @@ public function update(array $data)
172169
*
173170
* @see https://docs.hetzner.cloud/#zone-actions-change-zone-protection
174171
*
175-
* @param bool $delete
172+
* @param bool $delete
176173
* @return APIResponse|null
177174
*
178175
* @throws \LKDev\HetznerCloud\APIException
179176
*/
180177
public function changeProtection(bool $delete = true): ?APIResponse
181178
{
182-
$response = $this->httpClient->post('zones/' . $this->id . '/actions/change_protection', [
179+
$response = $this->httpClient->post('zones/'.$this->id.'/actions/change_protection', [
183180
'json' => [
184181
'delete' => $delete,
185182
],
186183
]);
187-
if (!HetznerAPIClient::hasError($response)) {
184+
if (! HetznerAPIClient::hasError($response)) {
188185
return APIResponse::create([
189-
'action' => Action::parse(json_decode((string)$response->getBody())->action),
186+
'action' => Action::parse(json_decode((string) $response->getBody())->action),
190187
], $response->getHeaders());
191188
}
192189

193190
return null;
194191
}
195192

196193
/**
197-
* @param string $uri
194+
* @param string $uri
198195
* @return string
199196
*/
200197
protected function replaceZoneIdInUri(string $uri): string
@@ -215,5 +212,3 @@ public static function parse($input)
215212
return (new self($input->id))->setAdditionalData($input);
216213
}
217214
}
218-
219-

src/Models/Zones/ZoneRequestOpts.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class ZoneRequestOpts extends RequestOpts
2222
/**
2323
* RequestOpts constructor.
2424
*
25-
* @param string|null $name
26-
* @param string|null $mode
27-
* @param int|null $perPage
28-
* @param int|null $page
29-
* @param string|null $labelSelector
25+
* @param string|null $name
26+
* @param string|null $mode
27+
* @param int|null $perPage
28+
* @param int|null $page
29+
* @param string|null $labelSelector
3030
*/
3131
public function __construct(?string $name = null, ?string $mode = null, ?int $perPage = null, ?int $page = null, ?string $labelSelector = null)
3232
{

0 commit comments

Comments
 (0)