In case your problem is with conveying the caseid e.g. from the customer via phone to the help desk you might consider leaving the actual case id as-is but change the alphabet/set of digits when showing it.
E.g. switch from decimal to hexadecimal and you've increased the range of values that can be displayed as four digits/characters from 9999 to 65535 (hex:ffff).
Now consider a different set of digits like 3479ACEFHJKLMNPRTUVWXY
* and the range of numbers that can be displayed using only four digits/characters increases quite a lot.
<?php
echo getCode(234255), "\r\n"; // up until "here": four digits
echo getCode(234256), "\r\n"; // ok, now it's five
echo getCode(5100000), "\r\n"; // but stays five until > 5 millions
function toBase(/* positiv integer*/ $n, array $alphabet) {
$retval = '';
do {
$retval = $alphabet[ $n%count($alphabet) ] . $retval;
$n = intval( $n / count($alphabet) );
}
while( ($n=intval($n)) > 0);
return $retval;
}
function getCode(/*int*/ $caseid) {
static $alphabet = ['3','4','7','9','A','C','E','F','H','J','K','L','M','N','P','R','T','U','V','W','X','Y'];
return toBase($caseid, $alphabet);
}
prints
YYYY
43333
YTYAA
*) an alphabet containing only unambiguous characters.