Przeglądaj źródła

Documentation changes and improvements

Jan Oris 9 lat temu
rodzic
commit
317545bdad
2 zmienionych plików z 39 dodań i 8 usunięć
  1. 13 8
      src/Ixudra/Curl/Builder.php
  2. 26 0
      src/Ixudra/Curl/CurlService.php

+ 13 - 8
src/Ixudra/Curl/Builder.php

@@ -25,6 +25,7 @@ class Builder {
 
     /**
      *  Set the URL to which the request is to be sent
+     * @param $url string   The URL to which the request is to be sent
      * @return $this
      */
     public function to($url)
@@ -33,7 +34,8 @@ class Builder {
     }
 
     /**
-     *  Set the request timeout (default 30 seconds)
+     *  Set the request timeout
+     * @param $timeout integer  The timeout for the request (in seconds. Default: 30 seconds)
      * @return $this
      */
     public function withTimeout($timeout = 30)
@@ -107,7 +109,7 @@ class Builder {
     }
 
     /**
-     *  Set the request timeout (default 30 seconds)
+     *  Add a HTTP header to the request
      * @param $header string    The HTTP header that is to be added to the request
      * @return $this
      */
@@ -118,6 +120,7 @@ class Builder {
 
     /**
      *  Send a GET request to a URL using the specified cURL options
+     * @return mixed
      */
     public function get()
     {
@@ -133,6 +136,7 @@ class Builder {
 
     /**
      *  Send a POST request to a URL using the specified cURL options
+     * @return mixed
      */
     public function post()
     {
@@ -155,6 +159,7 @@ class Builder {
 
     /**
      *  Send a PUT request to a URL using the specified cURL options
+     * @return mixed
      */
     public function put()
     {
@@ -165,6 +170,7 @@ class Builder {
 
     /**
      *  Send a DELETE request to a URL using the specified cURL options
+     * @return mixed
      */
     public function delete()
     {
@@ -173,11 +179,9 @@ class Builder {
         return $this->send();
     }
 
-
-
-
     /**
      *  Send the request
+     * @return mixed
      */
     protected function send()
     {
@@ -186,18 +190,15 @@ class Builder {
             $this->withHeader( 'Content-Type: application/json' );
         }
 
-
         // Create the request with all specified options
         $this->curlObject = curl_init();
         $options = $this->forgeOptions();
         curl_setopt_array( $this->curlObject, $options );
 
-
         // Send the request
         $response = curl_exec( $this->curlObject );
         curl_close( $this->curlObject );
 
-
         // Decode the request if necessary
         if( $this->packageOptions[ 'asJson' ] ) {
             $response = json_decode($response);
@@ -207,6 +208,10 @@ class Builder {
         return $response;
     }
 
+    /**
+     *  Convert the curlOptions to an array of usable options for the cURL request
+     * @return array
+     */
     protected function forgeOptions()
     {
         $results = array();

+ 26 - 0
src/Ixudra/Curl/CurlService.php

@@ -3,6 +3,14 @@
 
 class CurlService {
 
+    /**
+     * @param $url
+     * @param array $getParameters
+     * @param bool $isJson
+     * @param array $curlOptions
+     * @return mixed
+     * @deprecated
+     */
     public function get($url, $getParameters = array(), $isJson = false, $curlOptions = array())
     {
         $curl = new Curl();
@@ -15,6 +23,15 @@ class CurlService {
         return $this->send( $curl, $isJson );
     }
 
+    /**
+     * @param $url
+     * @param array $getParameters
+     * @param $postParameters
+     * @param bool $isJson
+     * @param array $curlOptions
+     * @return mixed
+     * @deprecated
+     */
     public function post($url, $getParameters = array(), $postParameters, $isJson = false, $curlOptions = array())
     {
         $curl = new Curl();
@@ -35,6 +52,11 @@ class CurlService {
         return $this->send( $curl, $isJson );
     }
 
+    /**
+     * @param $curl
+     * @param $isJson
+     * @return mixed
+     */
     protected function send($curl, $isJson)
     {
         $response = $curl->send();
@@ -45,6 +67,10 @@ class CurlService {
         return $response;
     }
 
+    /**
+     * @param $url string   The URL to which the request is to be sent
+     * @return \Ixudra\Curl\Builder
+     */
     public function to($url)
     {
         $builder = new Builder();