42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Utilities;
|
|
|
|
final class FinanceLedgerFlowSummaryDataSource
|
|
{
|
|
public const MANUAL = '手动';
|
|
|
|
public const DIRECT = '银企直连';
|
|
|
|
public const NON_DIRECT = '非银企直连';
|
|
|
|
public const FILTER_UNFILLED = '__empty__';
|
|
|
|
public const OPTIONS = [self::MANUAL, self::DIRECT];
|
|
|
|
public const CONNECTION_OPTIONS = [self::NON_DIRECT, self::DIRECT];
|
|
|
|
public static function normalize(mixed $value): string
|
|
{
|
|
$text = trim((string) ($value ?? ''));
|
|
|
|
return in_array($text, self::OPTIONS, true) ? $text : '';
|
|
}
|
|
|
|
public static function connectionLabel(mixed $value, bool $autoDirect = false): string
|
|
{
|
|
return match (self::normalize($value)) {
|
|
self::DIRECT => self::DIRECT,
|
|
self::MANUAL => self::NON_DIRECT,
|
|
default => $autoDirect ? self::DIRECT : self::NON_DIRECT,
|
|
};
|
|
}
|
|
|
|
public static function normalizeConnectionLabel(mixed $value): string
|
|
{
|
|
$text = trim((string) ($value ?? ''));
|
|
|
|
return in_array($text, self::CONNECTION_OPTIONS, true) ? $text : '';
|
|
}
|
|
}
|