Skip to content

Commit 688f737

Browse files
committed
Adds HttpClient
1 parent 9f434a4 commit 688f737

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed

src/Client.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Http\Client;
4+
5+
/**
6+
* Interface for both HTTP Client type
7+
*
8+
* @author Márk Sági-Kazár [email protected]>
9+
*/
10+
interface Client extends PsrHttpClient, HttpClient
11+
{
12+
13+
}

src/HttpClient.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
3+
namespace Http\Client;
4+
5+
use Psr\Http\Message\StreamInterface;
6+
use Psr\Http\Message\UriInterface;
7+
use Psr\Http\Message\ResponseInterface;
8+
9+
/**
10+
* Interface for HTTP conventional methods
11+
*
12+
* @author Márk Sági-Kazár [email protected]>
13+
*/
14+
interface HttpClient
15+
{
16+
/**
17+
* Sends a GET request
18+
*
19+
* @param string|UriInterface $uri
20+
* @param array $headers
21+
* @param array $options
22+
*
23+
* @throws Exception
24+
*
25+
* @return ResponseInterface
26+
*/
27+
public function get($uri, array $headers = [], array $options = []);
28+
29+
/**
30+
* Sends an HEAD request
31+
*
32+
* @param string|UriInterface $uri
33+
* @param array $headers
34+
* @param array $options
35+
*
36+
* @throws Exception
37+
*
38+
* @return ResponseInterface
39+
*/
40+
public function head($uri, array $headers = [], array $options = []);
41+
42+
/**
43+
* Sends a TRACE request
44+
*
45+
* @param string|UriInterface $uri
46+
* @param array $headers
47+
* @param array $options
48+
*
49+
* @throws Exception
50+
*
51+
* @return ResponseInterface
52+
*/
53+
public function trace($uri, array $headers = [], array $options = []);
54+
55+
/**
56+
* Sends a POST request
57+
*
58+
* @param string|UriInterface $uri
59+
* @param array $headers
60+
* @param array|string|StreamInterface $data
61+
* @param array $files
62+
* @param array $options
63+
*
64+
* @throws Exception
65+
*
66+
* @return ResponseInterface
67+
*/
68+
public function post($uri, array $headers = [], $data = [], array $files = [], array $options = []);
69+
70+
/**
71+
* Sends a PUT request
72+
*
73+
* @param string|UriInterface $uri
74+
* @param array $headers
75+
* @param array|string|StreamInterface $data
76+
* @param array $files
77+
* @param array $options
78+
*
79+
* @throws Exception
80+
*
81+
* @return ResponseInterface
82+
*/
83+
public function put($uri, array $headers = [], $data = [], array $files = [], array $options = []);
84+
85+
/**
86+
* Sends a PATCH request
87+
*
88+
* @param string|UriInterface $uri
89+
* @param array $headers
90+
* @param array|string|StreamInterface $data
91+
* @param array $files
92+
* @param array $options
93+
*
94+
* @throws Exception
95+
*
96+
* @return ResponseInterface
97+
*/
98+
public function patch($uri, array $headers = [], $data = [], array $files = [], array $options = []);
99+
100+
/**
101+
* Sends a DELETE request
102+
*
103+
* @param string|UriInterface $uri
104+
* @param array $headers
105+
* @param array|string|StreamInterface $data
106+
* @param array $files
107+
* @param array $options
108+
*
109+
* @throws Exception
110+
*
111+
* @return ResponseInterface
112+
*/
113+
public function delete($uri, array $headers = [], $data = [], array $files = [], array $options = []);
114+
115+
/**
116+
* Sends an OPTIONS request
117+
*
118+
* @param string|UriInterface $uri
119+
* @param array $headers
120+
* @param array|string|StreamInterface $data
121+
* @param array $files
122+
* @param array $options
123+
*
124+
* @throws Exception
125+
*
126+
* @return ResponseInterface
127+
*/
128+
public function options($uri, array $headers = [], $data = [], array $files = [], array $options = []);
129+
130+
/**
131+
* Sends a request
132+
*
133+
* @param string $method
134+
* @param string|UriInterface $uri
135+
* @param array $headers
136+
* @param array|string|StreamInterface $data
137+
* @param array $files
138+
* @param array $options
139+
*
140+
* @throws Exception
141+
*
142+
* @return ResponseInterface
143+
*/
144+
public function send($method, $uri, array $headers = [], $data = [], array $files = [], array $options = []);
145+
}

0 commit comments

Comments
 (0)