Revision: 50
http://sourceforge.net/p/beeframework/code/50
Author: m_plomer
Date: 2013-08-17 14:55:22 +0000 (Sat, 17 Aug 2013)
Log Message:
-----------
- updated Bee_Utils_Strings (added $strict parameter to some methods)
Modified Paths:
--------------
trunk/framework/Bee/Utils/Strings.php
Modified: trunk/framework/Bee/Utils/Strings.php
===================================================================
--- trunk/framework/Bee/Utils/Strings.php 2013-07-30 20:03:50 UTC (rev 49)
+++ trunk/framework/Bee/Utils/Strings.php 2013-08-17 14:55:22 UTC (rev 50)
@@ -22,26 +22,36 @@
* @author Michael Plomer <mic...@it...>
*/
class Bee_Utils_Strings {
-
+
/**
* Enter description here...
*
* @param String $text
+ * @param bool $strict
* @return boolean
*/
- public static function hasLength($text) {
+ public static function hasLength($text, $strict=false) {
if(is_null($text)) {
return false;
}
- self::checkIsString($text);
+ if ($strict) {
+ self::checkIsString($text);
+ }
return (mb_strlen($text) > 0);
}
- public static function hasText($text) {
+ /**
+ * @param $text
+ * @param bool $strict
+ * @return bool
+ */
+ public static function hasText($text, $strict=false) {
if(is_null($text)) {
return false;
}
- self::checkIsString($text);
+ if ($strict) {
+ self::checkIsString($text);
+ }
return self::hasLength(trim(strval($text)));
}
@@ -118,17 +128,25 @@
}
}
return $result;
- }
-
- public static function startsWith($string, $prefix) {
+ }
+
+ /**
+ * @param $string
+ * @param $prefix
+ * @param bool $strict
+ * @return bool
+ */
+ public static function startsWith($string, $prefix, $strict=false) {
if(is_null($string)) {
return is_null($prefix);
}
if(is_null($prefix)) {
return false;
}
- self::checkIsString($string);
- self::checkIsString($prefix);
+ if ($strict) {
+ self::checkIsString($string);
+ self::checkIsString($prefix);
+ }
$prefTest = substr($string, 0, strlen($prefix));
return $prefTest === false ? "" === $prefix : $prefTest === $prefix;
}
@@ -152,18 +170,25 @@
}
return $str;
}
-
- public static function endsWith($string, $suffix) {
+
+ /**
+ * @param $string
+ * @param $suffix
+ * @param bool $strict
+ * @return bool
+ */
+ public static function endsWith($string, $suffix, $strict=false) {
if(is_null($string)) {
return is_null($suffix);
}
if(is_null($suffix)) {
return false;
}
- self::checkIsString($string);
- self::checkIsString($suffix);
+ if ($strict) {
+ self::checkIsString($string);
+ self::checkIsString($suffix);
+ }
$sufTest = substr($string, (-strlen($suffix)));
return $sufTest === $string || $sufTest === false ? "" === $suffix : $sufTest === $suffix;
}
}
-?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|