| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function markup($message) |
||
| 31 | { |
||
| 32 | @trigger_error('"httplug_markup" twig extension is deprecated since version 1.17 and will be removed in 2.0. Use "@Httplug/http_message.html.twig" template instead.', E_USER_DEPRECATED); |
||
|
|
|||
| 33 | |||
| 34 | $safeMessage = htmlentities($message); |
||
| 35 | $parts = preg_split('|\\r?\\n\\r?\\n|', $safeMessage, 2); |
||
| 36 | |||
| 37 | if (!isset($parts[1])) { |
||
| 38 | // This is not a HTTP message |
||
| 39 | return $safeMessage; |
||
| 40 | } |
||
| 41 | |||
| 42 | if (empty($parts[1])) { |
||
| 43 | $parts[1] = '(This message has no captured body)'; |
||
| 44 | } |
||
| 45 | |||
| 46 | // make header names bold |
||
| 47 | $headers = preg_replace("|\n(.*?): |si", "\n<b>$1</b>: ", $parts[0]); |
||
| 48 | |||
| 49 | return sprintf("%s\n\n<div class='httplug-http-body httplug-hidden'>%s</div>", $headers, $parts[1]); |
||
| 50 | } |
||
| 51 | |||
| 57 |
If you suppress an error, we recommend checking for the error condition explicitly: