Skip to content

Commit 3c15039

Browse files
committed
feat: code-format
1 parent ecce23a commit 3c15039

File tree

52 files changed

+142
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+142
-168
lines changed

src/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/vendor
1111
.env
12-
.env.backup
13-
.env.prod
1412
.env.testing
1513
.phpactor.json
1614
.phpunit.result.cache

src/app/Console/Commands/AlgoliaImportWorldHeritages.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public function handle(): int
5151

5252
WorldHeritage::query()
5353
->with([
54-
'images' => function ($query) {
54+
'images' => static function ($query): void {
5555
$query->where('is_primary', true)->select(['world_heritage_site_id', 'url']);
5656
},
57-
'countries' => function ($query) {
57+
'countries' => static function ($query): void {
5858
$query->select(['countries.state_party_code', 'countries.name_en', 'countries.name_jp']);
5959
},
6060
])
@@ -69,12 +69,12 @@ public function handle(): int
6969
'world_heritage_sites.year_inscribed',
7070
'world_heritage_sites.is_endangered',
7171
])
72-
->chunkById($chunk, function ($rows) use ($client, $indexName, $dryRun, &$processed) {
72+
->chunkById($chunk, function ($rows) use ($client, $indexName, $dryRun, &$processed): void {
7373
$objects = [];
7474

7575
foreach ($rows as $row) {
7676
$countries = $row->countries
77-
->filter(fn ($country) => $country->state_party_code !== null)
77+
->filter(static fn ($country) => $country->state_party_code !== null)
7878
->values();
7979

8080
$statePartyCodes = $countries

src/app/Console/Commands/DumpUnescoWorldHeritageJson.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ private function resolveCountries(): array
403403
return [];
404404
}
405405
$lines = preg_split('/\R/u', (string) Storage::disk('local')->get($file)) ?: [];
406-
$items = array_map(fn ($v) => trim((string) $v), $lines);
406+
$items = array_map(static fn ($v) => trim((string) $v), $lines);
407407
return array_values(array_filter(array_unique($items)));
408408
}
409409

@@ -440,9 +440,9 @@ private function slugifyCountry(string $country): string
440440

441441
private function normalizeRow(array $row): array
442442
{
443-
$toBool = fn ($v) => is_bool($v) ? $v : (strtolower(trim((string) $v)) === 'true');
444-
$toFloat = fn ($v) => $v === null || $v === '' ? null : (float) $v;
445-
$toInt = fn ($v) => $v === null || $v === '' ? null : (int) $v;
443+
$toBool = static fn ($v) => is_bool($v) ? $v : (strtolower(trim((string) $v)) === 'true');
444+
$toFloat = static fn ($v) => $v === null || $v === '' ? null : (float) $v;
445+
$toInt = static fn ($v) => $v === null || $v === '' ? null : (int) $v;
446446

447447
$images = [];
448448
if (isset($row['images_urls']) && is_string($row['images_urls'])) {

src/app/Console/Commands/DumpWorldHeritageSiteJapaneseName.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function handle(): int
123123
$sid = (string) $id;
124124
$url = "{$baseUrl}/{$sid}";
125125

126-
$this->line("[$i/" . (count($targets) - 1) . "] {$url}");
126+
$this->line("[{$i}/" . (count($targets) - 1) . "] {$url}");
127127

128128
$html = $this->fetchHtml($url, $timeout);
129129
if ($html === null) {
@@ -250,7 +250,7 @@ private function loadExistingRows(string $out): array
250250
return [];
251251
}
252252

253-
return array_values(array_filter($json, fn ($v) => is_array($v)));
253+
return array_values(array_filter($json, static fn ($v) => is_array($v)));
254254
}
255255

256256
private function containsJapanese(string $s): bool

src/app/Console/Commands/ImportWorldHeritageJapaneseNameFromJson.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function handle(): int
5959
$existingIds = WorldHeritage::query()
6060
->whereIn('id', $ids)
6161
->pluck('id')
62-
->map(fn ($id) => (int) $id)
62+
->map(static fn ($id) => (int) $id)
6363
->all();
6464

6565
$existingIdSet = array_fill_keys($existingIds, true);
@@ -120,7 +120,7 @@ public function handle(): int
120120
try {
121121
$chunkIdList = array_column($upsertRows, 'id');
122122
$cases = implode(' ', array_map(
123-
fn ($row) => "WHEN {$row['id']} THEN ?",
123+
static fn ($row) => "WHEN {$row['id']} THEN ?",
124124
$upsertRows
125125
));
126126
$bindings = array_column($upsertRows, 'name_jp');
@@ -217,7 +217,7 @@ private function handleMissingIds(array $missing): void
217217
$dir = dirname($fullOut);
218218

219219
if (!is_dir($dir)) {
220-
@mkdir($dir, 0777, true);
220+
@mkdir($dir, 0o777, true);
221221
}
222222

223223
$content = implode(PHP_EOL, $missing) . PHP_EOL;

src/app/Console/Commands/ImportWorldHeritageSiteImagesFromJson.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ private function collectJsonFiles(string $fullPath): array
148148
);
149149

150150
foreach ($rii as $file) {
151-
if ($file->isFile() && str_ends_with($file->getFilename(), '.json')) {
152-
$files[] = $file->getPathname();
153-
}
151+
if (!($file->isFile() && str_ends_with($file->getFilename(), '.json'))) { continue; }
152+
153+
$files[] = $file->getPathname();
154154
}
155155

156156
sort($files);

src/app/Console/Commands/SplitWorldHeritageJson.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function handle(): int
7676
}
7777

7878
$outDir = $this->resolvePathToDir($out);
79-
if (!is_dir($outDir) && (!@mkdir($outDir, 0777, true) && !is_dir($outDir))) {
79+
if (!is_dir($outDir) && (!@mkdir($outDir, 0o777, true) && !is_dir($outDir))) {
8080
$this->error("Failed to create output dir: {$outDir}");
8181
return self::FAILURE;
8282
}
@@ -756,7 +756,7 @@ private function mergeSiteRowPreferExisting(array $existing, array $incoming): a
756756
}
757757
}
758758

759-
$fill = function (string $key, mixed $value) use (&$existing): void {
759+
$fill = static function (string $key, mixed $value) use (&$existing): void {
760760
if ((!array_key_exists($key, $existing) || $existing[$key] === null || $existing[$key] === '') && ($value !== null && $value !== '')) {
761761
$existing[$key] = $value;
762762
}

src/app/Console/Commands/WorldHeritageBuild.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function handle(): int
7676
'--out' => $dumpOut, // e.g. unesco/world-heritage-sites.json
7777
'--pretty' => $pretty ? true : null,
7878
'--dry-run' => (bool) $this->option('dump-dry-run') ? true : null,
79-
], fn ($v) => $v !== null));
79+
], static fn ($v) => $v !== null));
8080
}
8181

8282
// 1) Split raw UNESCO JSON -> normalized JSON files
@@ -88,7 +88,7 @@ public function handle(): int
8888
'--exceptions-out' => self::NORM_DIR . '/exceptions-missing-iso-codes.json',
8989
'--clean' => true,
9090
'--pretty' => $pretty ? true : null,
91-
], fn ($v) => $v !== null));
91+
], static fn ($v) => $v !== null));
9292

9393
// 2) Import countries (FK parent)
9494
$this->callOrFail('world-heritage:import-countries-split', [
@@ -137,14 +137,14 @@ public function handle(): int
137137

138138
'--missing-out' => trim((string) $this->option('jp-missing-out')) !== '' ? (string) $this->option('jp-missing-out') : null,
139139
'--missing-limit' => (int) $this->option('jp-missing-limit'),
140-
], fn ($v) => $v !== null));
140+
], static fn ($v) => $v !== null));
141141
}
142142

143143
// 8) Algolia import (optional)
144144
if ((bool) $this->option('algolia')) {
145145
$this->callOrFail('algolia:import-world-heritages', array_filter([
146146
'--truncate' => (bool) $this->option('algolia-truncate') ? true : null,
147-
], fn ($v) => $v !== null));
147+
], static fn ($v) => $v !== null));
148148
}
149149

150150
$this->info('Done: DB rebuilt + UNESCO data imported (dump -> split -> import)');

src/app/Enums/Region.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/app/Packages/Domains/Adapter/AlgoliaWorldHeritageSearchAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ public function search(
109109
'hitsPerPage' => $perPage,
110110
'filters' => $hasAnyFilter ? implode(' AND ', $filters) : null,
111111
],
112-
fn ($v) => $v !== null,
112+
static fn ($v) => $v !== null,
113113
),
114114
);
115115

116116
$hits = $response['hits'] ?? [];
117117

118-
$ids = array_values(array_filter(array_map(function (array $h) {
118+
$ids = array_values(array_filter(array_map(static function (array $h) {
119119
return isset($h['id'])
120120
? (int) $h['id']
121121
: (isset($h['objectID']) ? (int) $h['objectID'] : null);

0 commit comments

Comments
 (0)