23
23
*
24
24
* @package Cake.Utility
25
25
*/
26
- class String {
26
+ class CakeText {
27
27
28
28
/**
29
29
* Generate a random UUID
@@ -181,7 +181,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
181
181
/**
182
182
* Replaces variable placeholders inside a $str with any given $data. Each key in the $data array
183
183
* corresponds to a variable placeholder name in $str.
184
- * Example: `String ::insert(':name is :age years old.', array('name' => 'Bob', '65'));`
184
+ * Example: `CakeText ::insert(':name is :age years old.', array('name' => 'Bob', '65'));`
185
185
* Returns: Bob is 65 years old.
186
186
*
187
187
* Available $options are:
@@ -191,7 +191,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
191
191
* - escape: The character or string used to escape the before character / string (Defaults to `\`)
192
192
* - format: A regex to use for matching variable placeholders. Default is: `/(?<!\\)\:%s/`
193
193
* (Overwrites before, after, breaks escape / clean)
194
- * - clean: A boolean or array with instructions for String ::cleanInsert
194
+ * - clean: A boolean or array with instructions for CakeText ::cleanInsert
195
195
*
196
196
* @param string $str A string containing variable placeholders
197
197
* @param string $data A key => val array where each key stands for a placeholder variable name
@@ -207,7 +207,7 @@ public static function insert($str, $data, $options = array()) {
207
207
$ format = $ options ['format ' ];
208
208
$ data = (array )$ data ;
209
209
if (empty ($ data )) {
210
- return ($ options ['clean ' ]) ? String ::cleanInsert ($ str , $ options ) : $ str ;
210
+ return ($ options ['clean ' ]) ? CakeText ::cleanInsert ($ str , $ options ) : $ str ;
211
211
}
212
212
213
213
if (!isset ($ format )) {
@@ -226,7 +226,7 @@ public static function insert($str, $data, $options = array()) {
226
226
$ offset = $ pos + strlen ($ val );
227
227
$ str = substr_replace ($ str , $ val , $ pos , 1 );
228
228
}
229
- return ($ options ['clean ' ]) ? String ::cleanInsert ($ str , $ options ) : $ str ;
229
+ return ($ options ['clean ' ]) ? CakeText ::cleanInsert ($ str , $ options ) : $ str ;
230
230
} else {
231
231
asort ($ data );
232
232
@@ -251,19 +251,19 @@ public static function insert($str, $data, $options = array()) {
251
251
if (!isset ($ options ['format ' ]) && isset ($ options ['before ' ])) {
252
252
$ str = str_replace ($ options ['escape ' ] . $ options ['before ' ], $ options ['before ' ], $ str );
253
253
}
254
- return ($ options ['clean ' ]) ? String ::cleanInsert ($ str , $ options ) : $ str ;
254
+ return ($ options ['clean ' ]) ? CakeText ::cleanInsert ($ str , $ options ) : $ str ;
255
255
}
256
256
257
257
/**
258
- * Cleans up a String ::insert() formatted string with given $options depending on the 'clean' key in
258
+ * Cleans up a CakeText ::insert() formatted string with given $options depending on the 'clean' key in
259
259
* $options. The default method used is text but html is also available. The goal of this function
260
260
* is to replace all whitespace and unneeded markup around placeholders that did not get replaced
261
- * by String ::insert().
261
+ * by CakeText ::insert().
262
262
*
263
263
* @param string $str
264
264
* @param string $options
265
265
* @return string
266
- * @see String ::insert()
266
+ * @see CakeText ::insert()
267
267
*/
268
268
public static function cleanInsert ($ str , $ options ) {
269
269
$ clean = $ options ['clean ' ];
@@ -292,7 +292,7 @@ public static function cleanInsert($str, $options) {
292
292
$ str = preg_replace ($ kleenex , $ clean ['replacement ' ], $ str );
293
293
if ($ clean ['andText ' ]) {
294
294
$ options ['clean ' ] = array ('method ' => 'text ' );
295
- $ str = String ::cleanInsert ($ str , $ options );
295
+ $ str = CakeText ::cleanInsert ($ str , $ options );
296
296
}
297
297
break ;
298
298
case 'text ' :
0 commit comments