51 lines
1.3 KiB
PHP
51 lines
1.3 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 STORED_OPTIONS = [self::MANUAL, self::DIRECT, self::NON_DIRECT];
|
|
|
|
public const CONNECTION_OPTIONS = [self::NON_DIRECT, self::DIRECT];
|
|
|
|
public static function normalize(mixed $value): string
|
|
{
|
|
$text = self::stored($value);
|
|
|
|
return $text === self::NON_DIRECT ? self::MANUAL : $text;
|
|
}
|
|
|
|
public static function stored(mixed $value): string
|
|
{
|
|
$text = trim((string) ($value ?? ''));
|
|
|
|
return in_array($text, self::STORED_OPTIONS, true) ? $text : '';
|
|
}
|
|
|
|
public static function connectionLabel(mixed $value, bool $autoDirect = false): string
|
|
{
|
|
return match (self::stored($value)) {
|
|
self::DIRECT => self::DIRECT,
|
|
self::NON_DIRECT => 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 : '';
|
|
}
|
|
}
|