| Conditions | 2 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public static function wordwrap($str, $width, $break = "\n") |
||
| 23 | { |
||
| 24 | $length = 0; |
||
| 25 | return implode(" ", array_map(function ($word) use (&$length, $width, $break) { |
||
| 26 | $length += (mb_strlen($word) + 1); |
||
| 27 | |||
| 28 | if ($length > $width) { |
||
| 29 | $length = mb_strlen($break); |
||
| 30 | return sprintf("%s%s", $break, $word); |
||
| 31 | } |
||
| 32 | |||
| 33 | return $word; |
||
| 34 | }, explode(" ", $str))); |
||
| 35 | } |
||
| 36 | |||
| 46 |