Skip to content

Commit

Permalink
Full command import dso20
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane MEAUDRE committed Mar 25, 2024
1 parent 3f35622 commit ef5f35b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
7 changes: 5 additions & 2 deletions api/src/Command/ImportData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Command;

use App\State\CatalogsMapping;

trait ImportData
{
private function openFile(string $file): ?array
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion api/src/Services/DeepUtf8Encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
54 changes: 54 additions & 0 deletions api/src/State/CatalogsMapping.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace App\State;

class CatalogsMapping
{
public const UNASSIGNED = 'unassigned';

private static array $catalogMapping = [
'NG' => '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;
}
}

0 comments on commit ef5f35b

Please sign in to comment.