From ef5f35bcc2afd4030a058e7c2aecdc91d839c39f Mon Sep 17 00:00:00 2001 From: Stephane MEAUDRE Date: Mon, 25 Mar 2024 12:24:19 +0100 Subject: [PATCH] Full command import dso20 --- api/src/Command/ImportData.php | 7 +++- api/src/Services/DeepUtf8Encoding.php | 5 ++- api/src/State/CatalogsMapping.php | 54 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 api/src/State/CatalogsMapping.php diff --git a/api/src/Command/ImportData.php b/api/src/Command/ImportData.php index cc7c79f..f4d5fe3 100644 --- a/api/src/Command/ImportData.php +++ b/api/src/Command/ImportData.php @@ -2,6 +2,8 @@ namespace App\Command; +use App\State\CatalogsMapping; + trait ImportData { private function openFile(string $file): ?array @@ -17,10 +19,11 @@ public static function md5ForId(string $id): string public static function getCatalog(?string $id): string { + $catalogMapping = new CatalogsMapping; if (!is_null($id)) { - return Utils::getCatalogMapping()[substr($id, 0, 2)] ?? Utils::UNASSIGNED; + return $catalogMapping()[substr($id, 0, 2)] ?? CatalogsMapping::UNASSIGNED; } - return Utils::UNASSIGNED; + return CatalogsMapping::UNASSIGNED; } public static function getItemOrder(string $id): ?int diff --git a/api/src/Services/DeepUtf8Encoding.php b/api/src/Services/DeepUtf8Encoding.php index 5074134..8fe1d91 100644 --- a/api/src/Services/DeepUtf8Encoding.php +++ b/api/src/Services/DeepUtf8Encoding.php @@ -4,8 +4,11 @@ class DeepUtf8Encoding { - public function __invoke(string|int|float|array|object &$input): array|object|false|string|null + public function __invoke(string|int|float|array|object|null &$input): array|object|false|string|null { + if (is_null($input)) { + return $input; + } if (is_int($input) || is_float($input)) { return $input; } diff --git a/api/src/State/CatalogsMapping.php b/api/src/State/CatalogsMapping.php new file mode 100644 index 0000000..9847cb5 --- /dev/null +++ b/api/src/State/CatalogsMapping.php @@ -0,0 +1,54 @@ + 'ngc', + 'IC' => 'ic', + 'LD' => 'ldn', + 'Sh' => 'sh', + 'Cr' => 'cr', + 'St' => 'sto', + 'Ab' => 'abl', + 'UG' => 'ugc', + 'An' => self::UNASSIGNED, 'Ap' => self::UNASSIGNED, 'AP' => self::UNASSIGNED, + 'He' => self::UNASSIGNED, + 'Ba' => self::UNASSIGNED, 'Be' => self::UNASSIGNED, 'Bi' => self::UNASSIGNED, 'Bo' => self::UNASSIGNED, 'Bv' => self::UNASSIGNED, + 'B1' => self::UNASSIGNED, 'B2' => self::UNASSIGNED, 'B3' => self::UNASSIGNED, 'B4' => self::UNASSIGNED, 'B5' => self::UNASSIGNED, 'B6' => self::UNASSIGNED, 'B7' => self::UNASSIGNED, 'B8' => self::UNASSIGNED, 'B9' => self::UNASSIGNED, + 'K1' => self::UNASSIGNED, 'K2' => self::UNASSIGNED, 'K3' => self::UNASSIGNED, 'K4' => self::UNASSIGNED, + 'M1' => self::UNASSIGNED, 'M2' => self::UNASSIGNED, 'M3' => self::UNASSIGNED, 'M4' => self::UNASSIGNED, 'M7' => self::UNASSIGNED, + 'Mr' => self::UNASSIGNED, + 'Na' => self::UNASSIGNED, + 'Cz' => 'cz', + 'Ki' => 'kin', + 'Do' => self::UNASSIGNED, + 'Pa' => self::UNASSIGNED, 'Pe' => self::UNASSIGNED, + 'Ce' => self::UNASSIGNED, + 'Ru' => self::UNASSIGNED, + 'Ly' => 'lyn', + 'Ha' => self::UNASSIGNED, 'Ho' => self::UNASSIGNED, 'Hu' => self::UNASSIGNED, + 'H1' => self::UNASSIGNED, 'H2' => self::UNASSIGNED, + 'vd' => self::UNASSIGNED, + 'Ca' => self::UNASSIGNED, + 'La' => self::UNASSIGNED, + 'Me' => self::UNASSIGNED, + '3C' => self::UNASSIGNED, + 'Te' => self::UNASSIGNED, 'To' => self::UNASSIGNED, 'Tr' => self::UNASSIGNED, + 'Gu' => self::UNASSIGNED, 'Gr' => self::UNASSIGNED, + 'Pi' => self::UNASSIGNED, + 'Fe' => self::UNASSIGNED, + 'Ro' => self::UNASSIGNED, + 'Jo' => self::UNASSIGNED, + 'J3' => self::UNASSIGNED, 'J9' => self::UNASSIGNED, + 'Vd' => 'vdb', 'VV' => self::UNASSIGNED, 'vy' => self::UNASSIGNED, 'VY' => self::UNASSIGNED + ]; + + public function __invoke(): array + { + return self::$catalogMapping; + } +}