home_of( $url ); $response = wp_safe_remote_request( $home, array( 'method' => self::HEAD_METHOD, 'timeout' => self::TIMEOUT_SECONDS, 'redirection' => self::FOLLOWED_REDIRECTS, 'user-agent' => PluginUserAgent::NAME, ) ); $code = (int) wp_remote_retrieve_response_code( $response ); return $this->is_answering( $code ) ? $home : null; } private function home_of( string $url ): string { $scheme = (string) wp_parse_url( $url, PHP_URL_SCHEME ); $host = (string) wp_parse_url( $url, PHP_URL_HOST ); return strtolower( $scheme . self::SCHEME_SEPARATOR . $host ) . self::HOME_PATH; } private function is_answering( int $code ): bool { return self::FIRST_ANSWERING_CODE <= $code && self::FIRST_FAILING_CODE > $code; } }