getMessage(); $http_status = 0; if (preg_match('/\b(4\d{2}|5\d{2})\b/', $message, $matches)) { $http_status = (int) $matches[1]; } return self::fromError($message, $http_status, $provider); } /** * Check if error message matches any indicators. * * @param string $error_lower Lowercase error message. * @param array $indicators Array of indicator strings. * @return bool True if any indicator matches. */ private static function matchesIndicators(string $error_lower, array $indicators): bool { foreach ($indicators as $indicator) { if (strpos($error_lower, $indicator) !== false) { return true; } } return false; } /** * Parse retry-after seconds from error message. * * @param string $error_message Error message. * @return int Seconds to wait (default 60). */ private static function parseRetryAfter(string $error_message): int { if (preg_match('/retry.?after[:\s]+(\d+)/i', $error_message, $matches)) { return (int) $matches[1]; } if (preg_match('/wait[:\s]+(\d+)\s*seconds?/i', $error_message, $matches)) { return (int) $matches[1]; } if (preg_match('/in\s+(\d+)\s*seconds?/i', $error_message, $matches)) { return (int) $matches[1]; } return 60; } }