1 | <?php |
||
17 | abstract class Text |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Truncates the value string with the provided length |
||
22 | * |
||
23 | * If the string length is lower the the desired truncate length |
||
24 | * the value is returned intact. |
||
25 | * |
||
26 | * If the string is bigger then the provided length then it will |
||
27 | * be cut and the a terminator will be added to the end of the string. |
||
28 | * |
||
29 | * If you specify $preserve arg as true the world will be preserved |
||
30 | * when cutting the string and the cut will occur on the next available |
||
31 | * space character counting from the provided length. |
||
32 | * |
||
33 | * @param string $value |
||
34 | * @param int $length |
||
35 | * @param string $terminator |
||
36 | * @param bool $preserve |
||
37 | * |
||
38 | * @return string The truncate string |
||
39 | */ |
||
40 | public static function truncate( |
||
52 | |||
53 | /** |
||
54 | * Wraps a string to a given number of characters using a string |
||
55 | * break character. |
||
56 | * |
||
57 | * @param string $value The input string. |
||
58 | * @param int $length The number of characters at which the string |
||
59 | * will be wrapped. |
||
60 | * @param string $break The line is broken using the optional |
||
61 | * break parameter. |
||
62 | * @param bool $cut If the cut is set to TRUE, the string is always |
||
63 | * wrapped at or before the specified width. So if |
||
64 | * you have a word that is larger than the given |
||
65 | * width, it is broken apart. When FALSE the function |
||
66 | * does not split the word even if the width is |
||
67 | * smaller than the word width. |
||
68 | * |
||
69 | * @return string Returns the given string wrapped at the specified length. |
||
70 | */ |
||
71 | public static function wordwrap( |
||
76 | |||
77 | /** |
||
78 | * Check truncate length to avoid split a word |
||
79 | * |
||
80 | * @param string $value |
||
81 | * @param int $length |
||
82 | * |
||
83 | * @return int |
||
84 | */ |
||
85 | private static function preserveBreakpoint($value, $length) |
||
97 | } |
||
98 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: