Files
saasshop/app/Support/RunId.php

25 lines
539 B
PHP

<?php
namespace App\Support;
class RunId
{
public static function short(string $runId, int $head = 6, int $tail = 4, string $ellipsis = '…'): string
{
$runId = trim((string) $runId);
if ($runId === '') {
return '';
}
$len = strlen($runId);
if ($len <= ($head + $tail + 1)) {
return $runId;
}
$head = max(1, (int) $head);
$tail = max(1, (int) $tail);
return substr($runId, 0, $head) . $ellipsis . substr($runId, -$tail);
}
}