Skip to content

Commit f182253

Browse files
committed
fix: 🐛 avoid generating api resouce json files for non-existent postal codes
1 parent 1829a0a commit f182253

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/FileSystem/BaseDirectory.php

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

55
namespace Ttskch\JpPostalCodeApi\FileSystem;
66

7-
use Ttskch\JpPostalCodeApi\Model\Address;
87
use Ttskch\JpPostalCodeApi\Model\AddressUnit;
98
use Ttskch\JpPostalCodeApi\Model\ApiResource;
109
use Ttskch\JpPostalCodeApi\Model\ParsedCsvRow;
@@ -74,6 +73,11 @@ public function putJsonFile(ParsedCsvRow $row, bool $en = false): void
7473
}
7574
}
7675

76+
// For postal codes where only English addresses exist in the CSV
77+
if ([] === $apiResource->addresses) {
78+
return;
79+
}
80+
7781
$json = json_encode($apiResource, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
7882

7983
file_put_contents($jsonFilePath, $json);

0 commit comments

Comments
 (0)