Upload files to "/"

This commit is contained in:
2026-04-20 19:46:36 +03:00
parent 52325d11a3
commit 1078fd77f9

View File

@@ -2,12 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
/** /**
* Copyright (c) 2026 Panariga, All rights reserved. * Copyright (c) 2026 Panariga, All rights reserved.
* Comprehensive IBAN validator and utility class. * Comprehensive IBAN validator and utility class.
* Self-updating: Can parse official SWIFT iban-registry-v{version}.txt to update its own source. * Self-updating: Can parse official SWIFT iban-registry-v{version}.txt to update its own source.
* https://www.swift.com/standards/data-standards/iban-international-bank-account-number#topic-tabs-menu * https://www.swift.com/standards/data-standards/iban-international-bank-account-number#topic-tabs-menu
* *
* @author panariga <panariga@gmail.com>
*/ */
class IbanTools class IbanTools
{ {
@@ -442,7 +444,7 @@ class IbanTools
public static function updateRegistry(string $txtFilePath): void public static function updateRegistry(string $txtFilePath): void
{ {
if (!file_exists($txtFilePath)) { if (!file_exists($txtFilePath)) {
throw new RuntimeException("Registry file not found: $txtFilePath"); throw new \RuntimeException("Registry file not found: $txtFilePath");
} }
$raw_data = file_get_contents($txtFilePath); $raw_data = file_get_contents($txtFilePath);
@@ -465,7 +467,7 @@ class IbanTools
$countries = $registry['IBAN prefix country code (ISO 3166)'] ?? []; $countries = $registry['IBAN prefix country code (ISO 3166)'] ?? [];
if (empty($countries)) { if (empty($countries)) {
throw new RuntimeException("Could not find country codes in TSV. Ensure you have the raw SWIFT IBAN_Registry.txt."); throw new \RuntimeException("Could not find country codes in TSV. Ensure you have the raw SWIFT IBAN_Registry.txt.");
} }
$newRegistryBlocks = []; $newRegistryBlocks = [];
@@ -532,7 +534,7 @@ class IbanTools
ksort($newRegistryBlocks); ksort($newRegistryBlocks);
$newRegistryString = "[\n" . implode("\n", $newRegistryBlocks) . "\n ]"; $newRegistryString = "[\n" . implode("\n", $newRegistryBlocks) . "\n ]";
$classFile = (new ReflectionClass(self::class))->getFileName(); $classFile = (new \ReflectionClass(self::class))->getFileName();
$content = file_get_contents($classFile); $content = file_get_contents($classFile);
$startToken = 'private const REGISTRY = ['; $startToken = 'private const REGISTRY = [';
$endToken = ' ];'; $endToken = ' ];';
@@ -544,7 +546,7 @@ class IbanTools
file_put_contents($classFile, $updatedContent); file_put_contents($classFile, $updatedContent);
echo "✅ Successfully synced " . count($newRegistryBlocks) . " countries and updated " . basename($classFile) . "!\n"; echo "✅ Successfully synced " . count($newRegistryBlocks) . " countries and updated " . basename($classFile) . "!\n";
} else { } else {
throw new RuntimeException("Failed to locate REGISTRY array block in source file."); throw new \RuntimeException("Failed to locate REGISTRY array block in source file.");
} }
} }