Conditions | 3 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
12 | 121 | public static function from(Expectation $expectation): callable |
|
13 | { |
||
14 | 121 | return function ($request) use ($expectation) { |
|
15 | /** @var RequestInterface $request */ |
||
16 | 58 | $stream = $request->getBody(); |
|
17 | 58 | $stream->rewind(); |
|
18 | 58 | $body = $stream->getContents(); |
|
19 | |||
20 | 58 | foreach ($expectation->bodyHandlersIterator() as $handler) { |
|
21 | 2 | if (!$handler($body)) { |
|
22 | 1 | return new RejectedPromise('body does not match expectation'); |
|
23 | } |
||
24 | } |
||
25 | |||
26 | 57 | return $request; |
|
27 | }; |
||
30 |