Source for file String.php
Documentation is available at String.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 11: */
- 15: /**
- 16: * String tools library.
- 17: *
- 20: */
- 22: {
- 24: /**
- 25: * Static class - cannot be instantiated.
- 26: */
- 28: {
- 30: }
- 34: /**
- 35: * Checks if the string is valid for the specified encoding.
- 39: */
- 41: {
- 43: }
- 47: /**
- 48: * Returns correctly encoded string.
- 52: */
- 54: {
- 55: // removes xD800-xDFFF, xFEFF, xFFFF, x110000 and higher
- 57: }
- 61: /**
- 62: * Returns a specific character.
- 66: */
- 68: {
- 70: }
- 74: /**
- 75: * Starts the $haystack string with the prefix $needle?
- 79: */
- 81: {
- 83: }
- 87: /**
- 88: * Ends the $haystack string with the suffix $needle?
- 92: */
- 94: {
- 96: }
- 100: /**
- 101: * Removes special controls characters and normalizes line endings and spaces.
- 104: */
- 106: {
- 107: // standardize line endings to unix-like
- 111: // remove control characters; leave \t + \n
- 114: // right trim
- 117: // trailing spaces
- 121: }
- 125: /**
- 126: * Converts to web safe characters [a-z0-9-] text.
- 131: */
- 133: {
- 138: ."\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe",
- 142: }
- 148: }
- 152: /**
- 153: * Truncates string to maximal length.
- 158: */
- 160: {
- 171: }
- 172: }
- 174: }
- 178: /**
- 179: * Indents the content from the left.
- 184: */
- 186: {
- 187: return $level < 1 ? $s : preg_replace('#(?:^|[\r\n]+)(?=[^\r\n])#', '$0' . str_repeat($chars, $level), $s);
- 188: }
- 192: /**
- 193: * Convert to lower case.
- 196: */
- 198: {
- 200: }
- 204: /**
- 205: * Convert to upper case.
- 208: */
- 210: {
- 212: }
- 216: /**
- 217: * Capitalize string.
- 220: */
- 222: {
- 224: }
- 228: /**
- 229: * Strips whitespace.
- 233: */
- 235: {
- 238: }
- 242: /**
- 243: * Pad a string to a certain length with another string.
- 248: */
- 250: {
- 253: return str_repeat($pad, $length / $padLen) . iconv_substr($pad, 0, $length % $padLen, 'UTF-8') . $s;
- 254: }
- 258: /**
- 259: * Pad a string to a certain length with another string.
- 264: */
- 266: {
- 269: return $s . str_repeat($pad, $length / $padLen) . iconv_substr($pad, 0, $length % $padLen, 'UTF-8');
- 270: }
- 272: }