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 for an emptystring like ""
16: * @var string
17: */
18: public static $emptyString = "";
19:
20: /**
21: * A Constant for an quotechars like "
22: * @var string
23: */
24: public static $quotes = "\"";
25:
26: /**
27: * Method check if a certain string start with a certain substring
28: * @param string $haystack
29: * @param string $needle
30: * @return boolean
31: */
32: public static function startsWith($haystack, $needle) {
33: return !strncmp($haystack, $needle, strlen($needle));
34: }
35:
36: /**
37: * Method check if a certain string end with a certain substring
38: * @param string $haystack
39: * @param string $needle
40: * @return boolean
41: */
42: public static function endsWith($haystack, $needle) {
43: return (substr($haystack, -strlen($needle)) === $needle);
44: }
45:
46: /**
47: * Method if the string is not a empty String (not only spaces and controlls)
48: * @param string $string
49: * @return boolean
50: */
51: public static function validSQLString($string) {
52: if (!ctype_space($string) && !ctype_cntrl($string)) {
53: return TRUE;
54: }
55: return FALSE;
56: }
57:
58: /**
59: * Method if the string is in integor
60: * @param string $value
61: * @return boolean
62: */
63: public static function validInt($value) {
64: if (!ctype_digit($value) || PHP_INT_MAX < $value) {
65: return FALSE;
66: }
67: return TRUE;
68: }
69:
70: }
71:
72: ?>
73: