parser = $parser; } /** * @param string $url * * @return Readme * * @throws RuntimeException */ public function download( $url ) { $response = wp_safe_remote_get( $url ); $http_code = wp_remote_retrieve_response_code( $response ); $body = wp_remote_retrieve_body( $response ); if ( 200 === $http_code ) { return $this->parser->parse( $body ); } throw new RuntimeException( 'Readme could not be downloaded.' ); } }