@@ -26,7 +26,7 @@ class PendingRequest
2626 protected  $ factory ;
2727
2828 /** 
29-  * The client instance. 
29+  * The Guzzle  client instance. 
3030 * 
3131 * @var \GuzzleHttp\Client 
3232 */ 
@@ -595,6 +595,27 @@ public function delete($url, $data = [])
595595 ]);
596596 }
597597
598+  /** 
599+  * Send a pool of asynchronous requests concurrently. 
600+  * 
601+  * @param callable $callback 
602+  * @return array 
603+  */ 
604+  public  function  pool (callable  $ callback )
605+  {
606+  $ results  = [];
607+ 
608+  $ requests  = tap (new  Pool ($ this  ->factory ), $ callback )->getRequests ();
609+ 
610+  foreach  ($ requests  as  $ key  => $ item ) {
611+  $ results [$ key ] = $ item  instanceof  static ? $ item ->getPromise ()->wait () : $ item ->wait ();
612+  }
613+ 
614+  ksort ($ results );
615+ 
616+  return  $ results ;
617+  }
618+ 
598619 /** 
599620 * Send the request to the given URL. 
600621 * 
@@ -742,19 +763,6 @@ protected function populateResponse(Response $response)
742763 return  $ response ;
743764 }
744765
745-  /** 
746-  * Set the client instance. 
747-  * 
748-  * @param \GuzzleHttp\Client $client 
749-  * @return $this 
750-  */ 
751-  public  function  setClient (Client   $ client )
752-  {
753-  $ this  ->client  = $ client ;
754- 
755-  return  $ this  ;
756-  }
757- 
758766 /** 
759767 * Build the Guzzle client. 
760768 * 
@@ -932,33 +940,25 @@ public function async(bool $async = true)
932940 }
933941
934942 /** 
935-  * Send a pool of asynchronous requests concurrently . 
943+  * Retrieve the pending request promise . 
936944 * 
937-  * @param callable $callback 
938-  * @return array 
945+  * @return \GuzzleHttp\Promise\PromiseInterface|null 
939946 */ 
940-  public  function  pool ( callable   $ callback  )
947+  public  function  getPromise ( )
941948 {
942-  $ results  = [];
943- 
944-  $ requests  = tap (new  Pool ($ this  ->factory ), $ callback )->getRequests ();
945- 
946-  foreach  ($ requests  as  $ key  => $ item ) {
947-  $ results [$ key ] = $ item  instanceof  static ? $ item ->getPromise ()->wait () : $ item ->wait ();
948-  }
949- 
950-  ksort ($ results );
951- 
952-  return  $ results ;
949+  return  $ this  ->promise ;
953950 }
954951
955952 /** 
956-  * Retrieve  the pending request promise . 
953+  * Set  the client instance . 
957954 * 
958-  * @return \GuzzleHttp\Promise\PromiseInterface|null 
955+  * @param \GuzzleHttp\Client $client 
956+  * @return $this 
959957 */ 
960-  public  function  getPromise ( )
958+  public  function  setClient ( Client   $ client  )
961959 {
962-  return  $ this  ->promise ;
960+  $ this  ->client  = $ client ;
961+ 
962+  return  $ this  ;
963963 }
964964}
0 commit comments