24 lines
620 B
PHP
24 lines
620 B
PHP
<?php
|
|
|
|
namespace App\Support\Legacy;
|
|
|
|
final class Carrier
|
|
{
|
|
public static function toCode(?string $raw): string
|
|
{
|
|
$raw = trim((string)$raw);
|
|
if ($raw === '') return (string) config('legacy.carrier.default', 'n');
|
|
|
|
$upper = strtoupper($raw);
|
|
|
|
// 이미 코드면 그대로
|
|
$allowed = (array) config('legacy.carrier.allowed_codes', ['n']);
|
|
if (in_array($upper, $allowed, true)) {
|
|
return $upper;
|
|
}
|
|
|
|
$map = (array) config('legacy.carrier.codes', []);
|
|
return (string) ($map[$upper] ?? config('legacy.carrier.default', 'n'));
|
|
}
|
|
}
|