1: <?php
2:
3: namespace utiliy;
4:
5: include_once "../../global.inc.php";
6:
7: /**
8: * The StringManager provides some string-methods
9: * @author stubbfel
10: * @since 25.06.2013
11: */
12: class StringManager {
13:
14: /**
15: * A Constant vor an emptystring like ""
16: * @var string
17: */
18: public static $emptyString = "";
19:
20: /**
21: * Method check if a certain string start with a certain substring
22: * @param string $haystack
23: * @param string $needle
24: * @return boolean
25: */
26: public static function startsWith($haystack, $needle) {
27: return !strncmp($haystack, $needle, strlen($needle));
28: }
29:
30: /**
31: * Method check if a certain string end with a certain substring
32: * @param string $haystack
33: * @param string $needle
34: * @return boolean
35: */
36: public static function endsWith($haystack, $needle) {
37: return (substr($haystack, -strlen($needle)) === $needle);
38: }
39:
40: /**
41: * Method if the string is not a empty String (not only spaces and controlls)
42: * @param string $string
43: * @return boolean
44: */
45: public static function validSQLString($string) {
46: if (!ctype_space($string) && !ctype_cntrl($string)) {
47: return TRUE;
48: }
49: return FALSE;
50: }
51:
52: }
53:
54: ?>
55: