31 lines
693 B
PHP
Executable File
31 lines
693 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
class InternoSort
|
|
{
|
|
/**
|
|
* @return array{0:string,1:int,2:string}
|
|
*/
|
|
public static function key(?string $interno): array
|
|
{
|
|
$s = trim((string) ($interno ?? ''));
|
|
if ($s === '' || $s === '—') {
|
|
return ['~', PHP_INT_MAX, ''];
|
|
}
|
|
|
|
$u = strtoupper($s);
|
|
|
|
$m = null;
|
|
if (preg_match('/^([A-Z]+)\s*[-\/]\s*(\d+)(.*)$/', $u, $m)) {
|
|
return [$m[1], (int) $m[2], trim((string) ($m[3] ?? ''))];
|
|
}
|
|
|
|
if (preg_match('/^(\d+)(.*)$/', $u, $m)) {
|
|
return ['', (int) $m[1], trim((string) ($m[2] ?? ''))];
|
|
}
|
|
|
|
return [$u, PHP_INT_MAX, $u];
|
|
}
|
|
}
|