Rewrote a bit:
[core.git] / framework / main / classes / class_BaseFrameworkSystem.php
index cc2a0d4498982baf8c96835228947e3ae33e4f82..2d9aa984a4c0102d7cc91596fb616e1abddcd56d 100644 (file)
@@ -1983,8 +1983,22 @@ Loaded includes:
         *
         * @param       $str    The string with maybe dashes inside
         * @return      $str    The converted string with no dashed, but underscores
-        */
-       public static final function convertDashesToUnderscores ($str) {
+        * @throws      NullPointerException    If $str is null
+        * @throws      InvalidArgumentException        If $str is empty
+        */
+       public static function convertDashesToUnderscores ($str) {
+               // Is it null?
+               if (is_null($str)) {
+                       // Throw NPE
+                       throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
+               } elseif (!is_string($str)) {
+                       // Entry is empty
+                       throw new InvalidArgumentException(sprintf('str[]=%s is not a string', gettype($str)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+               } elseif ((is_string($str)) && (empty($str))) {
+                       // Entry is empty
+                       throw new InvalidArgumentException('str is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+               }
+
                // Convert them all
                $str = str_replace('-', '_', $str);