Skip to content

Commit 111199c

Browse files
committed
Drop options from interfaces, fixes #63
1 parent a67e769 commit 111199c

File tree

4 files changed

+38
-70
lines changed

4 files changed

+38
-70
lines changed

spec/HttpMethodsSpec.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,56 @@ function it_sends_a_get_request()
1717
{
1818
$data = HttpMethodsStub::$requestData;
1919

20-
$this->get($data['uri'], $data['headers'], $data['options'])->shouldReturn(true);
20+
$this->get($data['uri'], $data['headers'])->shouldReturn(true);
2121
}
2222

2323
function it_sends_a_head_request()
2424
{
2525
$data = HttpMethodsStub::$requestData;
2626

27-
$this->head($data['uri'], $data['headers'], $data['options'])->shouldReturn(true);
27+
$this->head($data['uri'], $data['headers'])->shouldReturn(true);
2828
}
2929

3030
function it_sends_a_trace_request()
3131
{
3232
$data = HttpMethodsStub::$requestData;
3333

34-
$this->trace($data['uri'], $data['headers'], $data['options'])->shouldReturn(true);
34+
$this->trace($data['uri'], $data['headers'])->shouldReturn(true);
3535
}
3636

3737
function it_sends_a_post_request()
3838
{
3939
$data = HttpMethodsStub::$requestData;
4040

41-
$this->post($data['uri'], $data['headers'], $data['body'], $data['options'])->shouldReturn(true);
41+
$this->post($data['uri'], $data['headers'], $data['body'])->shouldReturn(true);
4242
}
4343

4444
function it_sends_a_put_request()
4545
{
4646
$data = HttpMethodsStub::$requestData;
4747

48-
$this->put($data['uri'], $data['headers'], $data['body'], $data['options'])->shouldReturn(true);
48+
$this->put($data['uri'], $data['headers'], $data['body'])->shouldReturn(true);
4949
}
5050

5151
function it_sends_a_patch_request()
5252
{
5353
$data = HttpMethodsStub::$requestData;
5454

55-
$this->patch($data['uri'], $data['headers'], $data['body'], $data['options'])->shouldReturn(true);
55+
$this->patch($data['uri'], $data['headers'], $data['body'])->shouldReturn(true);
5656
}
5757

5858
function it_sends_a_delete_request()
5959
{
6060
$data = HttpMethodsStub::$requestData;
6161

62-
$this->delete($data['uri'], $data['headers'], $data['body'], $data['options'])->shouldReturn(true);
62+
$this->delete($data['uri'], $data['headers'], $data['body'])->shouldReturn(true);
6363
}
6464

6565
function it_sends_a_options_request()
6666
{
6767
$data = HttpMethodsStub::$requestData;
6868

69-
$this->options($data['uri'], $data['headers'], $data['body'], $data['options'])->shouldReturn(true);
69+
$this->options($data['uri'], $data['headers'], $data['body'])->shouldReturn(true);
7070
}
7171
}
7272

@@ -80,9 +80,6 @@ class HttpMethodsStub implements HttpMethodsClient
8080
'Content-Type' => 'text/plain',
8181
],
8282
'body' => 'body',
83-
'options' => [
84-
'timeout' => 60,
85-
],
8683
];
8784

8885
/**
@@ -93,14 +90,12 @@ public function send($method, $uri, array $headers = [], $body = null, array $op
9390
if (in_array($method, ['GET', 'HEAD', 'TRACE'])) {
9491
return $uri === self::$requestData['uri'] &&
9592
$headers === self::$requestData['headers'] &&
96-
is_null($body) &&
97-
$options === self::$requestData['options'];
93+
is_null($body);
9894
}
9995

10096
return in_array($method, ['POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']) &&
10197
$uri === self::$requestData['uri'] &&
10298
$headers === self::$requestData['headers'] &&
103-
$body === self::$requestData['body'] &&
104-
$options === self::$requestData['options'];
99+
$body === self::$requestData['body'];
105100
}
106101
}

src/HttpMethods.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,69 +14,69 @@ trait HttpMethods
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
public function get($uri, array $headers = [], array $options = [])
17+
public function get($uri, array $headers = [])
1818
{
19-
return $this->send('GET', $uri, $headers, null, $options);
19+
return $this->send('GET', $uri, $headers, null);
2020
}
2121

2222
/**
2323
* {@inheritdoc}
2424
*/
25-
public function head($uri, array $headers = [], array $options = [])
25+
public function head($uri, array $headers = [])
2626
{
27-
return $this->send('HEAD', $uri, $headers, null, $options);
27+
return $this->send('HEAD', $uri, $headers, null);
2828
}
2929

3030
/**
3131
* {@inheritdoc}
3232
*/
33-
public function trace($uri, array $headers = [], array $options = [])
33+
public function trace($uri, array $headers = [])
3434
{
35-
return $this->send('TRACE', $uri, $headers, null, $options);
35+
return $this->send('TRACE', $uri, $headers, null);
3636
}
3737

3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function post($uri, array $headers = [], $body = null, array $options = [])
41+
public function post($uri, array $headers = [], $body = null)
4242
{
43-
return $this->send('POST', $uri, $headers, $body, $options);
43+
return $this->send('POST', $uri, $headers, $body);
4444
}
4545

4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function put($uri, array $headers = [], $body = null, array $options = [])
49+
public function put($uri, array $headers = [], $body = null)
5050
{
51-
return $this->send('PUT', $uri, $headers, $body, $options);
51+
return $this->send('PUT', $uri, $headers, $body);
5252
}
5353

5454
/**
5555
* {@inheritdoc}
5656
*/
57-
public function patch($uri, array $headers = [], $body = null, array $options = [])
57+
public function patch($uri, array $headers = [], $body = null)
5858
{
59-
return $this->send('PATCH', $uri, $headers, $body, $options);
59+
return $this->send('PATCH', $uri, $headers, $body);
6060
}
6161

6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function delete($uri, array $headers = [], $body = null, array $options = [])
65+
public function delete($uri, array $headers = [], $body = null)
6666
{
67-
return $this->send('DELETE', $uri, $headers, $body, $options);
67+
return $this->send('DELETE', $uri, $headers, $body);
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function options($uri, array $headers = [], $body = null, array $options = [])
73+
public function options($uri, array $headers = [], $body = null)
7474
{
75-
return $this->send('OPTIONS', $uri, $headers, $body, $options);
75+
return $this->send('OPTIONS', $uri, $headers, $body);
7676
}
7777

7878
/**
7979
* {@inheritdoc}
8080
*/
81-
abstract public function send($method, $uri, array $headers = [], $body = null, array $options = []);
81+
abstract public function send($method, $uri, array $headers = [], $body = null);
8282
}

src/HttpMethodsClient.php

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
*
1212
* Use this interface when you do not have PSR-7 RequestInterface instances available.
1313
*
14-
* Implementations should be configured in their constructor. For runtime behaviour changes, there
15-
* is an $options parameter. It SHOULD be validated by the client and an exception thrown if
16-
* unknown options are passed.
17-
* Option that must be accepted by every client implementation (though it is free to ignore them
18-
* if the underlying implementation does not support the option):
19-
*
20-
* - timeout (int): the timeout for the HTTP request in seconds. 0 means to use the default.
21-
*
2214
* @author Márk Sági-Kazár [email protected]>
2315
*/
2416
interface HttpMethodsClient
@@ -28,109 +20,101 @@ interface HttpMethodsClient
2820
*
2921
* @param string|UriInterface $uri
3022
* @param array $headers
31-
* @param array $options
3223
*
3324
* @throws Exception
3425
*
3526
* @return ResponseInterface
3627
*/
37-
public function get($uri, array $headers = [], array $options = []);
28+
public function get($uri, array $headers = []);
3829

3930
/**
4031
* Sends an HEAD request
4132
*
4233
* @param string|UriInterface $uri
4334
* @param array $headers
44-
* @param array $options
4535
*
4636
* @throws Exception
4737
*
4838
* @return ResponseInterface
4939
*/
50-
public function head($uri, array $headers = [], array $options = []);
40+
public function head($uri, array $headers = []);
5141

5242
/**
5343
* Sends a TRACE request
5444
*
5545
* @param string|UriInterface $uri
5646
* @param array $headers
57-
* @param array $options
5847
*
5948
* @throws Exception
6049
*
6150
* @return ResponseInterface
6251
*/
63-
public function trace($uri, array $headers = [], array $options = []);
52+
public function trace($uri, array $headers = []);
6453

6554
/**
6655
* Sends a POST request
6756
*
6857
* @param string|UriInterface $uri
6958
* @param array $headers
7059
* @param string|Body|StreamInterface|null $body
71-
* @param array $options
7260
*
7361
* @throws Exception
7462
*
7563
* @return ResponseInterface
7664
*/
77-
public function post($uri, array $headers = [], $body = null, array $options = []);
65+
public function post($uri, array $headers = [], $body = null);
7866

7967
/**
8068
* Sends a PUT request
8169
*
8270
* @param string|UriInterface $uri
8371
* @param array $headers
8472
* @param string|Body|StreamInterface|null $body
85-
* @param array $options
8673
*
8774
* @throws Exception
8875
*
8976
* @return ResponseInterface
9077
*/
91-
public function put($uri, array $headers = [], $body = null, array $options = []);
78+
public function put($uri, array $headers = [], $body = null);
9279

9380
/**
9481
* Sends a PATCH request
9582
*
9683
* @param string|UriInterface $uri
9784
* @param array $headers
9885
* @param string|Body|StreamInterface|null $body
99-
* @param array $options
10086
*
10187
* @throws Exception
10288
*
10389
* @return ResponseInterface
10490
*/
105-
public function patch($uri, array $headers = [], $body = null, array $options = []);
91+
public function patch($uri, array $headers = [], $body = null);
10692

10793
/**
10894
* Sends a DELETE request
10995
*
11096
* @param string|UriInterface $uri
11197
* @param array $headers
11298
* @param string|Body|StreamInterface|null $body
113-
* @param array $options
11499
*
115100
* @throws Exception
116101
*
117102
* @return ResponseInterface
118103
*/
119-
public function delete($uri, array $headers = [], $body = null, array $options = []);
104+
public function delete($uri, array $headers = [], $body = null);
120105

121106
/**
122107
* Sends an OPTIONS request
123108
*
124109
* @param string|UriInterface $uri
125110
* @param array $headers
126111
* @param string|Body|StreamInterface|null $body
127-
* @param array $options
128112
*
129113
* @throws Exception
130114
*
131115
* @return ResponseInterface
132116
*/
133-
public function options($uri, array $headers = [], $body = null, array $options = []);
117+
public function options($uri, array $headers = [], $body = null);
134118

135119
/**
136120
* Sends a request
@@ -139,11 +123,10 @@ public function options($uri, array $headers = [], $body = null, array $options
139123
* @param string|UriInterface $uri
140124
* @param array $headers
141125
* @param string|Body|StreamInterface|null $body
142-
* @param array $options
143126
*
144127
* @throws Exception
145128
*
146129
* @return ResponseInterface
147130
*/
148-
public function send($method, $uri, array $headers = [], $body = null, array $options = []);
131+
public function send($method, $uri, array $headers = [], $body = null);
149132
}

src/HttpPsrClient.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99
/**
1010
* Sends one or more PSR-7 Request
1111
*
12-
* Implementations should be configured in their constructor. For runtime behaviour changes, there
13-
* is an $options parameter. It SHOULD be validated by the client and an exception thrown if
14-
* unknown options are passed.
15-
* Option that must be accepted by every client implementation (though it is free to ignore them
16-
* if the underlying implementation does not support the option):
17-
*
18-
* - timeout (int): the timeout for the HTTP request in seconds. 0 means to use the default.
19-
*
2012
* @author GeLo <[email protected]>
2113
*/
2214
interface HttpPsrClient
@@ -25,13 +17,12 @@ interface HttpPsrClient
2517
* Sends a PSR request
2618
*
2719
* @param RequestInterface $request
28-
* @param array $options
2920
*
3021
* @return ResponseInterface
3122
*
3223
* @throws Exception
3324
*/
34-
public function sendRequest(RequestInterface $request, array $options = []);
25+
public function sendRequest(RequestInterface $request);
3526

3627
/**
3728
* Sends PSR requests
@@ -40,12 +31,11 @@ public function sendRequest(RequestInterface $request, array $options = []);
4031
* The BatchException also gives access to the BatchResult for the successful responses.
4132
*
4233
* @param RequestInterface[] $requests
43-
* @param array $options
4434
*
4535
* @return BatchResult If all requests where successful.
4636
*
4737
* @throws Exception
4838
* @throws BatchException
4939
*/
50-
public function sendRequests(array $requests, array $options = []);
40+
public function sendRequests(array $requests);
5141
}

0 commit comments

Comments
 (0)