1 | <?php |
||
11 | final class Strings |
||
12 | { |
||
13 | /** |
||
14 | * Replaces the format items in a specified string with the string representation of n specified objects. |
||
15 | * |
||
16 | * @param string $format A composit format string |
||
17 | * @param mixed $arguments Variable number of items to format. |
||
18 | * |
||
19 | * @return string Returns a copy of format in which the format items have been |
||
20 | * replaced by the string representations of arg0, arg1,... argN. |
||
21 | */ |
||
22 | public static function format(string $format, string ...$arguments) : string |
||
30 | |||
31 | /** |
||
32 | * Checks if $string ends with $suffix and puts the rest of the $string in $nonSuffix. |
||
33 | * |
||
34 | * @param string $string The string to check |
||
35 | * @param string $suffix The suffix to check for |
||
36 | * @param mixed &$nonSuffix This is the part of the string that is not the suffix. |
||
37 | * |
||
38 | * @return bool whether the $string ended with $suffix or not. |
||
39 | */ |
||
40 | public static function endsWith(string $string, string $suffix, &$nonSuffix = null) : bool |
||
62 | |||
63 | /** |
||
64 | * Truncates the string to the given length, with an ellipsis at the end. |
||
65 | * |
||
66 | * @param string $string The string to shorten. |
||
67 | * @param int $maxLength The length to truncate the string to. The result will not be longer than this, but may be |
||
68 | * shorter. |
||
69 | * @param string $suffix The string to append when truncating. Typically this will be an ellipsis. |
||
70 | * |
||
71 | * @return string The truncated string with the ellipsis included if truncation occured. |
||
72 | * |
||
73 | * @throws \InvalidArgumentException if $maxLength is negative |
||
74 | */ |
||
75 | public static function ellipsize(string $string, int $maxLength, string $suffix = '...') : string |
||
94 | } |
||
95 |