1 | <?php namespace Gears\String\Methods; |
||
16 | trait Truncate |
||
17 | { |
||
18 | /** |
||
19 | * Truncates the string to a given length. |
||
20 | * |
||
21 | * If $substring is provided, and truncating occurs, the string is further |
||
22 | * truncated so that the substring may be appended without exceeding the |
||
23 | * desired length. |
||
24 | * |
||
25 | * @param int $length Desired length of the truncated string. |
||
26 | * |
||
27 | * @param string $substring The substring to append if it can fit. |
||
28 | * |
||
29 | * @return static String after truncating. |
||
30 | */ |
||
31 | public function truncate($length, $substring = '') |
||
49 | |||
50 | /** |
||
51 | * Truncates the string to a given length, |
||
52 | * while ensuring that it does not split words. |
||
53 | * |
||
54 | * If $substring is provided, and truncating occurs, the string is further |
||
55 | * truncated so that the substring may be appended without exceeding the |
||
56 | * desired length. |
||
57 | * |
||
58 | * @param int $length Desired length of the truncated string. |
||
59 | * |
||
60 | * @param string $substring The substring to append if it can fit. |
||
61 | * |
||
62 | * @return static |
||
63 | */ |
||
64 | public function safeTruncate($length, $substring = '') |
||
85 | } |
||
86 |