Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 03:12:48 +0000 (04:12 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 03:12:48 +0000 (04:12 +0100)
- moved away from monolithic BaseFrameworkSystem to proper classes

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/utils/number/class_NumberUtils.php
framework/main/classes/utils/string/class_StringUtils.php

index 5a5cb97a2c581e14439b281b6161c8ef97fb6b30..43146fc0ed40eb52a157c56e72bc6ff0986d2731 100644 (file)
@@ -1044,55 +1044,6 @@ Loaded includes:
                return self::$hashLength;
        }
 
-       /**
-        * Checks whether the given number is really a number (only chars 0-9).
-        *
-        * @param       $num            A string consisting only chars between 0 and 9
-        * @param       $castValue      Whether to cast the value to double. Do only use this to secure numbers from Requestable classes.
-        * @param       $assertMismatch         Whether to assert mismatches
-        * @return      $ret            The (hopefully) secured numbered value
-        */
-       public function bigintval ($num, $castValue = true, $assertMismatch = false) {
-               // Filter all numbers out
-               $ret = preg_replace('/[^0123456789]/', '', $num);
-
-               // Shall we cast?
-               if ($castValue === true) {
-                       // Cast to biggest numeric type
-                       $ret = (double) $ret;
-               }
-
-               // Assert only if requested
-               if ($assertMismatch === true) {
-                       // Has the whole value changed?
-                       assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
-               }
-
-               // Return result
-               return $ret;
-       }
-
-       /**
-        * Checks whether the given hexadecimal number is really a hex-number (only chars 0-9,a-f).
-        *
-        * @param       $num    A string consisting only chars between 0 and 9
-        * @param       $assertMismatch         Whether to assert mismatches
-        * @return      $ret    The (hopefully) secured hext-numbered value
-        */
-       public function hexval ($num, $assertMismatch = false) {
-               // Filter all numbers out
-               $ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num);
-
-               // Assert only if requested
-               if ($assertMismatch === true) {
-                       // Has the whole value changed?
-                       assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
-               }
-
-               // Return result
-               return $ret;
-       }
-
        /**
         * Determines if an element is set in the generic array
         *
index 29afa81f2279fe0b1fd6b48fea98bd41e7743443..96d654aa414e38229fc316ae9cc769b9705c921f 100644 (file)
@@ -107,4 +107,32 @@ final class NumberUtils extends BaseFrameworkSystem {
                return $readable;
        }
 
+       /**
+        * Checks whether the given number is really a number (only chars 0-9).
+        *
+        * @param       $num            A string consisting only chars between 0 and 9
+        * @param       $castValue      Whether to cast the value to double. Do only use this to secure numbers from Requestable classes.
+        * @param       $assertMismatch         Whether to assert mismatches
+        * @return      $ret            The (hopefully) secured numbered value
+        */
+       public static function bigintval (string $num, bool $castValue = true, bool $assertMismatch = false) {
+               // Filter all numbers out
+               $ret = preg_replace('/[^0123456789]/', '', $num);
+
+               // Shall we cast?
+               if ($castValue === true) {
+                       // Cast to biggest numeric type
+                       $ret = (double) $ret;
+               }
+
+               // Assert only if requested
+               if ($assertMismatch === true) {
+                       // Has the whole value changed?
+                       assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
+               }
+
+               // Return result
+               return $ret;
+       }
+
 }
index d895d1911d15ab342cff8262bdde2ffa714e3009..e6c4c738cfc6364d98b297e3cf875ab14d075e39 100644 (file)
@@ -422,4 +422,25 @@ final class StringUtils extends BaseFrameworkSystem {
                return $packed;
        }
 
+       /**
+        * Checks whether the given hexadecimal number is really a hex-number (only chars 0-9,a-f).
+        *
+        * @param       $num    A string consisting only chars between 0 and 9
+        * @param       $assertMismatch         Whether to assert mismatches
+        * @return      $ret    The (hopefully) secured hext-numbered value
+        */
+       public static function hexval (string $num, bool $assertMismatch = false) {
+               // Filter all numbers out
+               $ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num);
+
+               // Assert only if requested
+               if ($assertMismatch === true) {
+                       // Has the whole value changed?
+                       assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
+               }
+
+               // Return result
+               return $ret;
+       }
+
 }