| Conditions | 3 |
| Paths | 2 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public static function serviceRespondedWithAnError(Response $response) |
||
| 11 | { |
||
| 12 | $responseBody = $response->getJSONDecodedBody(); |
||
| 13 | $errorMsg = $response->getHeader('X-Line-Request-Id').': '.$responseBody['message']; |
||
| 14 | |||
| 15 | if (preg_match('/The request body has [\d]+ errors?/', $responseBody['message'], $matches)) { |
||
| 16 | foreach ($responseBody['details'] as $detail) { |
||
| 17 | $errorMsg .= PHP_EOL.$detail['message']; |
||
| 18 | $errorMsg .= PHP_EOL.$detail['property']; |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | return new static($errorMsg); |
||
| 23 | } |
||
| 24 | |||
| 35 |