61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace utiliy;
|
|
|
|
include_once "../../global.inc.php";
|
|
|
|
/**
|
|
* The StringManager provides some string-methods
|
|
* @author stubbfel
|
|
* @since 25.06.2013
|
|
*/
|
|
class StringManager {
|
|
|
|
/**
|
|
* A Constant for an emptystring like ""
|
|
* @var string
|
|
*/
|
|
public static $emptyString = "";
|
|
|
|
/**
|
|
* A Constant for an quotechars like "
|
|
* @var string
|
|
*/
|
|
public static $quotes = "\"";
|
|
|
|
/**
|
|
* Method check if a certain string start with a certain substring
|
|
* @param string $haystack
|
|
* @param string $needle
|
|
* @return boolean
|
|
*/
|
|
public static function startsWith($haystack, $needle) {
|
|
return !strncmp($haystack, $needle, strlen($needle));
|
|
}
|
|
|
|
/**
|
|
* Method check if a certain string end with a certain substring
|
|
* @param string $haystack
|
|
* @param string $needle
|
|
* @return boolean
|
|
*/
|
|
public static function endsWith($haystack, $needle) {
|
|
return (substr($haystack, -strlen($needle)) === $needle);
|
|
}
|
|
|
|
/**
|
|
* Method if the string is not a empty String (not only spaces and controlls)
|
|
* @param string $string
|
|
* @return boolean
|
|
*/
|
|
public static function validSQLString($string) {
|
|
if (!ctype_space($string) && !ctype_cntrl($string)) {
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|