original_string: protected function downloadTempFile($url)
      {
          $temp = $this->file->getTempFile();
  
          $fh = fopen($temp, "w");
  
          if (!is_resource($fh)) {
              throw new UnexpectedValueException($this->translation->text('File handle is not a valid resource'));
          }
  
          $response = $this->http->request($url);
          fwrite($fh, $response['data']);
          fclose($fh);
  
          return $temp;
      }
code: protected function downloadTempFile($url)
      {
          $temp = $this->file->getTempFile();
  
          $fh = fopen($temp, "w");
  
          if (!is_resource($fh)) {
              throw new UnexpectedValueException($this->translation->text('File handle is not a valid resource'));
          }
  
          $response = $this->http->request($url);
          fwrite($fh, $response['data']);
          fclose($fh);
  
          return $temp;
      }
code_tokens: protected function downloadTempFile ( $ url ) { $ temp = $ this -> file -> getTempFile ( ) ; $ fh = fopen ( $ temp , "w" ) ; if ( ! is_resource ( $ fh ) ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'File handle is not a valid resource' ) ) ; } $ response = $ this -> http -> request ( $ url ) ; fwrite ( $ fh , $ response [ 'data' ] ) ; fclose ( $ fh ) ; return $ temp ; }
docstring: Writes a temporary file from a remote file
  @param string $url
  @return string
  @throws UnexpectedValueException
docstring_tokens: Writes a temporary file from a remote file