Skip to content

Commit 190474c

Browse files
committed
cs fixes
1 parent 2a72bdb commit 190474c

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

app/Console/Commands/PerformUpdate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class PerformUpdate extends Command
2828
/**
2929
* Execute the console command.
3030
*/
31-
public function handle()
31+
public function handle(): int
3232
{
33-
$targetVersion = $this->getVersionChoices();
33+
$targetVersion = $this->queryTargetVersion();
3434

3535
/** @var Site $site */
3636
$site = Site::findOrFail($this->input->getArgument('siteId'));

app/Console/Commands/QueueUpdates.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class QueueUpdates extends Command
3030
/**
3131
* Execute the console command.
3232
*/
33-
public function handle()
33+
public function handle(): int
3434
{
35-
$targetVersion = $this->getVersionChoices();
35+
$targetVersion = $this->queryTargetVersion();
3636

3737
$this->confirm("Are you sure you would like to push the updates for " . $targetVersion);
3838

app/Console/Traits/RequestTargetVersion.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66

77
trait RequestTargetVersion
88
{
9-
protected function getVersionChoices()
9+
protected function queryTargetVersion(): string
1010
{
1111
$releases = (new TufFetcher())->getReleases();
1212

13-
$targetVersion = $this->choice(
13+
return $this->choice( // @phpstan-ignore-line
1414
"What's the target version?",
15-
$releases->map(fn ($release) => $release["version"])->values()->toArray()
15+
$releases->map(fn ($release) => $release["version"])->values()->toArray() // @phpstan-ignore-line
1616
);
17-
18-
return $targetVersion;
1917
}
2018
}

app/Http/Controllers/Api/V1/SiteController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function register(SiteRequest $request): JsonResponse
4848
return $this->error($e->getMessage(), 500);
4949
}
5050

51-
// If successful save site
52-
$site = new Site();
51+
// If successful create or update site
52+
$site = Site::where('url', $url)->where('key', $key)->first() ?? new Site();
5353

5454
$site->key = $key;
5555
$site->url = $url;
@@ -77,14 +77,14 @@ public function check(SiteRequest $request): JsonResponse
7777

7878
try {
7979
/** @var Site $site */
80-
$site = Site::where('url', $url)->where('key', $key)->findOrFail();
80+
$site = Site::where('url', $url)->where('key', $key)->firstOrFail();
8181
} catch (\Exception $e) {
8282
return $this->error("Not found", 404);
8383
}
8484

8585
// Do a health check
8686
try {
87-
$site->getConnection()->checkHealth();
87+
$site->connection->checkHealth();
8888
} catch (ServerException|ClientException $e) {
8989
return $this->error($e->getMessage(), 400);
9090
} catch (\Exception $e) {
@@ -105,7 +105,7 @@ public function delete(SiteRequest $request): JsonResponse
105105
$key = $request->string('key');
106106

107107
try {
108-
$site = Site::where('url', $url)->where('key', $key)->findOrFail();
108+
$site = Site::where('url', $url)->where('key', $key)->firstOrFail();
109109
} catch (\Exception $e) {
110110
return $this->error("Not found", 404);
111111
}

app/Jobs/UpdateSite.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function handle(): void
6363
}
6464

6565
$prepareResult = $connection->prepareUpdate(["targetVersion" => $this->targetVersion]);
66+
6667
// Perform the actual extraction
6768
$this->performExtraction($prepareResult);
6869

app/RemoteSite/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* @method HealthCheckResponse checkHealth()
2222
* @method GetUpdateResponse getUpdate()
23-
* @method PrepareUpdateResponse prepareUpdate(string $targetVersion)
23+
* @method PrepareUpdateResponse prepareUpdate(array<string,string> $data)
2424
* @method FinalizeUpdateResponse finalizeUpdate()
2525
*/
2626
class Connection

0 commit comments

Comments
 (0)