1 | <?php |
||
19 | final class http |
||
20 | { |
||
21 | /** |
||
22 | * Send a HTTP request with a specific method, GET, POST, etc. |
||
23 | * @param null $method The method to use, GET, POST, etc. |
||
24 | * @param null $url The URL to request |
||
25 | * @param null $query The query string |
||
26 | * @param array $options Any of the HTTP stream context options, e.g. extra headers. |
||
27 | * @return string |
||
28 | */ |
||
29 | 1 | public static function request( $method = null, $url = null, $query = null, $options = [] ) |
|
35 | |||
36 | /** |
||
37 | * Create a new HTTP client with a default set of stream context options to use in all requests. |
||
38 | * @param array $options Any of the HTTP stream context options, e.g. extra headers. |
||
39 | * @return http\ClientStream |
||
40 | */ |
||
41 | 1 | public static function client( $options = [] ) |
|
45 | |||
46 | /** |
||
47 | * Do a HTTP GET request and return the response. |
||
48 | * @param $url The URL to request |
||
49 | * @param mixed $query The query parameters |
||
50 | * @param array $options Any of the HTTP stream context options, e.g. extra headers. |
||
51 | * @return string |
||
52 | */ |
||
53 | 1 | public static function get( $url, $query = null, $options = [] ) |
|
57 | |||
58 | /** |
||
59 | * Do a HTTP POST request and return the response. |
||
60 | * @param $url The URL to request |
||
61 | * @param mixed $query The query parameters |
||
62 | * @param array $options Any of the HTTP stream context options, e.g. extra headers. |
||
63 | * @return string |
||
64 | */ |
||
65 | public static function post( $url, $query = null, $options = [] ) |
||
69 | |||
70 | /** |
||
71 | * Do a HTTP PUT request and return the response. |
||
72 | * @param $url The URL to request |
||
73 | * @param mixed $query The query parameters |
||
74 | * @param array $options Any of the HTTP stream context options, e.g. extra headers. |
||
75 | */ |
||
76 | public static function put( $url, $query = null, $options = [] ) |
||
77 | { |
||
78 | return self::request( 'PUT', $url, $query, $options); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Do a HTTP DELETE request and return the response. |
||
83 | * @param $url The URL to request |
||
84 | * @param mixed $query The query parameters |
||
85 | * @param array $options Any of the HTTP stream context options, e.g. extra headers. |
||
86 | * @return string |
||
87 | */ |
||
88 | public static function delete( $url, $query = null, $options = [] ) |
||
92 | } |
||
93 |