summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/RegistrationNumber.php7
-rw-r--r--tests/RegistrationNumberTest.php6
2 files changed, 9 insertions, 4 deletions
diff --git a/src/RegistrationNumber.php b/src/RegistrationNumber.php
index 678633d..eca7166 100644
--- a/src/RegistrationNumber.php
+++ b/src/RegistrationNumber.php
@@ -383,11 +383,18 @@ final readonly class RegistrationNumber
private static function checkSuffix(
string $region, string $authority, string $sequence, string $suffix
): bool {
+ // Ensure the HK or Macau suffix is only available to Guangdong-Z
if (in_array($suffix, self::GUANGDONG_Z_SPECIAL_SUFFIXS, strict: true)) {
return $region === self::GUANGDONG_PROVINCE
&& $authority === self::GUANGDONG_SPECIAL_AUTHORITY;
}
+ // Ensure the Guangdong-Z license plate ends with either an "HK" or a "Macau" suffix
+ if ($region === self::GUANGDONG_PROVINCE
+ && $authority === self::GUANGDONG_SPECIAL_AUTHORITY) {
+ return in_array($suffix, self::GUANGDONG_Z_SPECIAL_SUFFIXS, strict: true);
+ }
+
if ($suffix !== '' && ! in_array($suffix, self::AVAILLABLE_SUFFIXS, strict: true)) {
$len = mb_strlen($sequence);
diff --git a/tests/RegistrationNumberTest.php b/tests/RegistrationNumberTest.php
index 6516eb3..96af23b 100644
--- a/tests/RegistrationNumberTest.php
+++ b/tests/RegistrationNumberTest.php
@@ -290,7 +290,8 @@ final class RegistrationNumberTest extends TestCase
['粤O12345'],
// Authority code "Z" (the 2nd character) is for internal in Guangdong province
- ['粤Z12345'],
+ ['粤Z1234港'],
+ ['粤Z12345港'],
// Authority code "W" (the 2nd character) is for internal in Shandong province
['鲁W12345'],
@@ -309,9 +310,6 @@ final class RegistrationNumberTest extends TestCase
// Authority code "O" (the 2nd character) is for internal
['粤OD12345'],
- // Authority code "Z" (the 2nd character) is for internal in Guangdong province
- ['粤ZD12345'],
-
// Authority code "W" (the 2nd character) is for internal in Shandong province
['鲁WD12345'],
];