| Conditions | 4 |
| Paths | 1 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | 121 | public static function from(Expectation $expectation): callable |
|
| 13 | { |
||
| 14 | 121 | return function ($request) use ($expectation) { |
|
| 15 | /** @var RequestInterface $request */ |
||
| 16 | 117 | parse_str($request->getUri()->getQuery(), $params); |
|
| 17 | |||
| 18 | 117 | foreach ($expectation->notEmptyQueryParamsIterator() as $param => $value) { |
|
| 19 | 16 | if (!array_key_exists($param, $params)) { |
|
| 20 | 4 | return new RejectedPromise('param \'' . $param . '\' is missing'); |
|
| 21 | } |
||
| 22 | |||
| 23 | 12 | if ($params[$param] !== $value) { |
|
| 24 | 7 | return new RejectedPromise('param \'' . $param . '\' does not match expectation'); |
|
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | 106 | return $request; |
|
| 29 | 121 | }; |
|
| 32 |