Updated-simplified calling codes for German mobile carriers

This commit is contained in:
Marko Jovanovic 2025-10-29 11:31:37 +01:00
parent 2a12b62d40
commit 60bc3e6e99

View File

@ -138,16 +138,18 @@ final class CleanMobileCommand extends Command
} }
// Extract the 3digit network prefix and the subscriber part // Extract the 3digit network prefix and the subscriber part
$prefix = substr($e164, 4, 3); // after 0049 $prefix = substr($e164, 4, 2); // after 0049
$subscriber = substr($e164, 7); $subscriber = substr($e164, 6);
// Prefix must be one of the known mobile prefixes // Prefix must be one of the known mobile prefixes
if (!in_array($prefix, $germanMobilePrefixes, true)) { if (!in_array($prefix, $germanMobilePrefixes, true)) {
return false; return false;
} }
// Subscriber must be 610 digits long and consist only of digits // Subscriber must be 611 digits long and consist only of digits
return preg_match('/^\d{6,10}$/', $subscriber) === 1; // (technically 6-10, but for simplification we consider first two as prefix,
// and the last digit of the prefix belongs to the subscriber)
return preg_match('/^\d{6,11}$/', $subscriber) === 1;
}; };
// ------------------------------------------------------------- // -------------------------------------------------------------