Skip to content

Commit b3066d1

Browse files
committed
Add docblock
1 parent ef33028 commit b3066d1

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/Test/HttpClient/MockHttpAdapter.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
use GuzzleHttp\Psr7\Response;
88
use Psr\Http\Message\RequestInterface;
99

10+
/**
11+
* HTTP adapter mock
12+
*
13+
* This mock is most useful in tests. It does not send requests but stores them
14+
* for later retrieval. Additionally, you can set an exception to test
15+
* exception handling.
16+
*/
1017
class MockHttpAdapter implements HttpAdapter
1118
{
12-
private $requests = array();
19+
private $requests = [];
1320
private $exception;
1421

1522
/**
@@ -18,11 +25,7 @@ class MockHttpAdapter implements HttpAdapter
1825
public function sendRequest(RequestInterface $request, array $options = [])
1926
{
2027
$this->requests[] = $request;
21-
22-
if ($this->exception) {
23-
throw $this->exception;
24-
}
25-
28+
2629
return new Response();
2730
}
2831

@@ -33,19 +36,19 @@ public function sendRequests(array $requests, array $options = [])
3336
{
3437
$responses = [];
3538
$exceptions = new MultiHttpAdapterException();
36-
39+
3740
foreach ($requests as $request) {
3841
try {
3942
$responses[] = $this->sendRequest($request);
4043
} catch (\Exception $e) {
4144
$exceptions->addException($e);
4245
}
4346
}
44-
47+
4548
if ($exceptions->hasExceptions()) {
4649
throw $exceptions;
4750
}
48-
51+
4952
return $responses;
5053
}
5154

@@ -63,12 +66,12 @@ public function getName()
6366
{
6467
return 'mock';
6568
}
66-
69+
6770
public function getRequests()
6871
{
6972
return $this->requests;
7073
}
71-
74+
7275
public function clear()
7376
{
7477
$this->exception = null;

0 commit comments

Comments
 (0)