9999) { throw new \InvalidArgumentException('Year must be four digits.'); } return sprintf('JC-%04d-%06d', $year, $sequence); } public static function isValid(string $reference): bool { return preg_match('/^JC-\d{4}-\d{6}$/', $reference) === 1; } }