1 | <?php namespace Gears\String\Methods; |
||
16 | trait Misc |
||
17 | { |
||
18 | /** |
||
19 | * Normalise all line endings in string to `$newLineEnding`. |
||
20 | * |
||
21 | * @link http://stackoverflow.com/questions/7836632 |
||
22 | * |
||
23 | * @param string $newLineEnding Defaults to a LINE FEED. You may provide |
||
24 | * any string to replace all line endings. |
||
25 | * |
||
26 | * @return static |
||
27 | */ |
||
28 | public function normaliseLineEndings($newLineEnding = "\n") |
||
32 | |||
33 | /** |
||
34 | * Returns a lowercase and trimmed string separated by the given delimiter. |
||
35 | * |
||
36 | * Delimiters are inserted before uppercase characters (with the exception |
||
37 | * of the first character of the string), and in place of spaces, dashes, |
||
38 | * and underscores. Alpha delimiters are not converted to lowercase. |
||
39 | * |
||
40 | * @param string $delimiter Sequence used to separate parts of the string |
||
41 | * |
||
42 | * @return static |
||
43 | */ |
||
44 | public function delimit($delimiter) |
||
53 | |||
54 | /** |
||
55 | * Inserts $substring into the string at the $index provided. |
||
56 | * |
||
57 | * @param string $substring String to be inserted. |
||
58 | * |
||
59 | * @param int $index The index at which to insert the substring. |
||
60 | * |
||
61 | * @return static String after the insertion. |
||
62 | * |
||
63 | * @throws \OutOfBoundsException When the index is greater than the length. |
||
64 | */ |
||
65 | public function insert($substring, $index) |
||
87 | |||
88 | /** |
||
89 | * Splits on newlines and carriage returns. |
||
90 | * |
||
91 | * @return static[] |
||
92 | */ |
||
93 | public function lines() |
||
97 | |||
98 | /** |
||
99 | * Returns a repeated string given a multiplier. |
||
100 | * |
||
101 | * @param int $multiplier The number of times to repeat the string |
||
102 | * |
||
103 | * @return static |
||
104 | */ |
||
105 | public function repeat($multiplier) |
||
112 | |||
113 | /** |
||
114 | * Returns a reversed string. A multibyte version of strrev(). |
||
115 | * |
||
116 | * @return static Object with a reversed $str |
||
117 | */ |
||
118 | public function reverse() |
||
122 | |||
123 | /** |
||
124 | * A multibyte string shuffle function. |
||
125 | * |
||
126 | * It returns a string with its characters in random order. |
||
127 | * |
||
128 | * @return static |
||
129 | */ |
||
130 | public function shuffle() |
||
134 | |||
135 | /** |
||
136 | * Returns the substring beginning at $start, and up to, but not including |
||
137 | * the index specified by $end. If $end is omitted, the function extracts |
||
138 | * the remaining string. If $end is negative, it is computed from the end |
||
139 | * of the string. |
||
140 | * |
||
141 | * @param int $start Initial index from which to begin extraction. |
||
142 | * |
||
143 | * @param int|null $end Optional index at which to end extraction. |
||
144 | * |
||
145 | * @return static The extracted substring. |
||
146 | */ |
||
147 | public function slice($start, $end = null) |
||
171 | |||
172 | /** |
||
173 | * Surrounds string with the given substring. |
||
174 | * |
||
175 | * @param string $substring The substring to add to both sides. |
||
176 | * |
||
177 | * @return static String with $substring both prepended |
||
178 | * and appended. |
||
179 | */ |
||
180 | public function surround($substring) |
||
187 | |||
188 | /** |
||
189 | * Returns a string with smart quotes, ellipsis characters, and dashes from |
||
190 | * Windows-1252 (commonly used in Word documents) replaced by their ASCII |
||
191 | * equivalents. |
||
192 | * |
||
193 | * @return static |
||
194 | */ |
||
195 | public function tidy() |
||
199 | |||
200 | /** |
||
201 | * Returns the number of occurrences of $substring in the given string. |
||
202 | * |
||
203 | * By default, the comparison is case-sensitive, but can be made |
||
204 | * insensitive by setting $caseSensitive to false. |
||
205 | * |
||
206 | * @param string $substring The substring to search for. |
||
207 | * |
||
208 | * @param bool $caseSensitive Whether or not to enforce case-sensitivity. |
||
209 | * |
||
210 | * @return int The number of $substring occurrences |
||
|
|||
211 | */ |
||
212 | public function countSubstr($substring, $caseSensitive = true) |
||
232 | |||
233 | /** |
||
234 | * Formats the current string, using the provided array of arguments. |
||
235 | * |
||
236 | * For details on the syntax of the $format string: |
||
237 | * http://php.net/manual/en/function.sprintf.php |
||
238 | * |
||
239 | * @param array $args The arguments that will be inserted |
||
240 | * into the $format string. |
||
241 | * |
||
242 | * @return static |
||
243 | */ |
||
244 | public function format($args) |
||
248 | } |
||
249 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.