Skip to content

Commit 2a97411

Browse files
committed
Fix cs
1 parent 285fdab commit 2a97411

File tree

6 files changed

+18
-22
lines changed

6 files changed

+18
-22
lines changed

app/Enum/WebserviceEndpoint.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
enum WebserviceEndpoint: string
66
{
7-
case HEALTH_CHECK = "/api/index.php/v1/updates/health";
8-
case FETCH_UPDATES = "/api/index.php/v1/updates/fetch";
9-
case PREPARE_UPDATE = "/api/index.php/v1/updates/prepare";
10-
case FINALIZE_UPDATE = "/api/index.php/v1/updates/finalize";
7+
case HEALTH_CHECK = "/api/index.php/v1/joomlaupdate/healthcheck";
8+
case FETCH_UPDATES = "/api/index.php/v1/joomlaupdate/fetchUpdate";
9+
case PREPARE_UPDATE = "/api/index.php/v1/joomlaupdate/prepareUpdate";
10+
case FINALIZE_UPDATE = "/api/index.php/v1/joomlaupdate/finalizeUpdate";
1111
}

app/Jobs/CheckSiteHealth.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace App\Jobs;
66

77
use App\Models\Site;
8-
use app\Remotesite\Connection;
8+
use App\RemoteSite\Connection;
99
use Carbon\Carbon;
1010
use Illuminate\Contracts\Queue\ShouldQueue;
1111
use Illuminate\Foundation\Queue\Queueable;
@@ -29,19 +29,11 @@ public function handle(): void
2929
/** @var Connection $connection */
3030
$connection = $this->site->connection;
3131

32-
$response = $connection->checkHealth();
33-
34-
$healthData = collect($response);
32+
$healthData = $connection->checkHealth();
3533

3634
// Write updated data to DB
3735
$this->site->fill(
38-
$healthData->only([
39-
'php_version',
40-
'db_type',
41-
'db_version',
42-
'cms_version',
43-
'server_os'
44-
])->toArray()
36+
$healthData->toArray()
4537
);
4638

4739
// @phpstan-ignore-next-line

app/Jobs/UpdateSite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace App\Jobs;
66

77
use App\Models\Site;
8-
use app\Remotesite\Connection;
8+
use App\RemoteSite\Connection;
99
use Illuminate\Contracts\Queue\ShouldQueue;
1010
use Illuminate\Foundation\Queue\Queueable;
1111

app/Models/Site.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace App\Models;
66

7-
use App\Remotesite\Connection;
7+
use App\RemoteSite\Connection;
88
use Illuminate\Database\Eloquent\Model;
99

1010
class Site extends Model

app/RemoteSite/Connection.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use App\Enum\HttpMethod;
88
use App\Enum\WebserviceEndpoint;
9-
use App\RemoteSite\Responses\HealthCheck;
109
use App\RemoteSite\Responses\HealthCheck as HealthCheckResponse;
1110
use GuzzleHttp\Client;
1211
use GuzzleHttp\Exception\RequestException;
@@ -21,14 +20,14 @@ public function __construct(protected readonly string $baseUrl, protected readon
2120
{
2221
}
2322

24-
public function checkHealth(): HealthCheck
23+
public function checkHealth(): HealthCheckResponse
2524
{
2625
$healthData = $this->performWebserviceRequest(
2726
HttpMethod::GET,
2827
WebserviceEndpoint::HEALTH_CHECK
2928
);
3029

31-
return HealthCheckResponse::from($healthData);
30+
return HealthCheckResponse::from($healthData['data']['attributes']);
3231
}
3332

3433
public function performExtractionRequest(array $data): array
@@ -58,7 +57,7 @@ protected function performWebserviceRequest(
5857
$method->name,
5958
$this->baseUrl . $endpoint->value,
6059
[
61-
'Authorization' => 'JUpdate-Token ' . $this->key
60+
'X-JUpdate-Token' => $this->key
6261
]
6362
);
6463

app/RemoteSite/Responses/BaseResponse.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
abstract class BaseResponse
66
{
7-
public static function from(array $data): self
7+
public static function from(array $data): static
88
{
99
$reflect = new \ReflectionClass(static::class);
1010
$properties = $reflect->getProperties(\ReflectionProperty::IS_PUBLIC);
@@ -21,4 +21,9 @@ public static function from(array $data): self
2121

2222
return $reflect->newInstanceArgs($arguments);
2323
}
24+
25+
public function toArray(): array
26+
{
27+
return get_object_vars($this);
28+
}
2429
}

0 commit comments

Comments
 (0)