original_string: public function create(Video $video, $waitForIngest = 0) {
          if(is_null($video)) {
              throw new VideoClientException("No video provided");
          }
  
          if(is_null($video->sourceUrl) || !filter_var($video->sourceUrl, FILTER_VALIDATE_URL)) {
              throw new VideoClientException("Invalid source URL");
          }
  
          $ingestedStatus = "INGESTED";
  
          try {
              // Make the request to the SafeStream REST API
              $videoResponse = $this->post($this->apiResourcePath, $video);
  
              // Wait for the video to be ingested before returning
              // TODO: Have the ingest wait be on a separate thread
              if($waitForIngest > 0 && !$ingestedStatus == $videoResponse->status) {
                  $startTime = round(microtime(true) * 1000);
                  $ingested = false;
                  while(!$ingested && (round(microtime(true) * 1000) - $startTime) < $waitForIngest) {
                      $test = $this->find($video->key);
                      if($ingestedStatus == $videoResponse->status) {
                          return $test;
                      }
  
                      sleep(3);
                  }
  
                  throw new VideoClientException("Timeout reached waiting for video to be ingested");
  
              } else {
                  return $videoResponse;
              }
          } catch(SafeStreamHttpException $e) {
              throw new VideoClientException($e);
          }
      }
code: public function create(Video $video, $waitForIngest = 0) {
          if(is_null($video)) {
              throw new VideoClientException("No video provided");
          }
  
          if(is_null($video->sourceUrl) || !filter_var($video->sourceUrl, FILTER_VALIDATE_URL)) {
              throw new VideoClientException("Invalid source URL");
          }
  
          $ingestedStatus = "INGESTED";
  
          try {
              // Make the request to the SafeStream REST API
              $videoResponse = $this->post($this->apiResourcePath, $video);
  
              // Wait for the video to be ingested before returning
              // TODO: Have the ingest wait be on a separate thread
              if($waitForIngest > 0 && !$ingestedStatus == $videoResponse->status) {
                  $startTime = round(microtime(true) * 1000);
                  $ingested = false;
                  while(!$ingested && (round(microtime(true) * 1000) - $startTime) < $waitForIngest) {
                      $test = $this->find($video->key);
                      if($ingestedStatus == $videoResponse->status) {
                          return $test;
                      }
  
                      sleep(3);
                  }
  
                  throw new VideoClientException("Timeout reached waiting for video to be ingested");
  
              } else {
                  return $videoResponse;
              }
          } catch(SafeStreamHttpException $e) {
              throw new VideoClientException($e);
          }
      }
code_tokens: public function create ( Video $ video , $ waitForIngest = 0 ) { if ( is_null ( $ video ) ) { throw new VideoClientException ( "No video provided" ) ; } if ( is_null ( $ video -> sourceUrl ) || ! filter_var ( $ video -> sourceUrl , FILTER_VALIDATE_URL ) ) { throw new VideoClientException ( "Invalid source URL" ) ; } $ ingestedStatus = "INGESTED" ; try { // Make the request to the SafeStream REST API $ videoResponse = $ this -> post ( $ this -> apiResourcePath , $ video ) ; // Wait for the video to be ingested before returning // TODO: Have the ingest wait be on a separate thread if ( $ waitForIngest > 0 && ! $ ingestedStatus == $ videoResponse -> status ) { $ startTime = round ( microtime ( true ) * 1000 ) ; $ ingested = false ; while ( ! $ ingested && ( round ( microtime ( true ) * 1000 ) - $ startTime ) < $ waitForIngest ) { $ test = $ this -> find ( $ video -> key ) ; if ( $ ingestedStatus == $ videoResponse -> status ) { return $ test ; } sleep ( 3 ) ; } throw new VideoClientException ( "Timeout reached waiting for video to be ingested" ) ; } else { return $ videoResponse ; } } catch ( SafeStreamHttpException $ e ) { throw new VideoClientException ( $ e ) ; } }
docstring: Creates a new video allowing a specific timeout while waiting for the video to downloaded
  and encoded. If not timeout is set then the function will return immediately, before the
  ingest is complete. The video cannot be watermarked until it has been ingested at which
  point the video status will be INGESTED.
  
  This will block until either the video is ingested OR the timeout is reached.
  
  @param Video $video
  @param int $waitForIngest: Time in millis to wait for the video to be ingested
  @return mixed: The newly created video
  @throws VideoClientException
docstring_tokens: Creates a new video allowing a specific timeout while waiting for the video to downloaded and encoded . If not timeout is set then the function will return immediately before the ingest is complete . The video cannot be watermarked until it has been ingested at which point the video status will be INGESTED .