]> git.mxchange.org Git - core.git/commitdiff
Rewrote a bit:
authorRoland Häder <roland@mxchange.org>
Sun, 13 Aug 2017 18:15:36 +0000 (20:15 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 13 Aug 2017 18:15:36 +0000 (20:15 +0200)
- removed redundant convertDashesToUnderscores() in FrameworkConfiguration but
  had to add an include line again, let's save redudant code, right? :-)

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/bootstrap/class_FrameworkBootstrap.php
framework/config/class_FrameworkConfiguration.php
framework/main/classes/class_BaseFrameworkSystem.php

index c759f9416512e0e083272d894c8bbdcecd4eae8d..a37c6bf95a8200fa770050389d007f1e52331033 100644 (file)
@@ -228,6 +228,7 @@ final class FrameworkBootstrap {
        public static function doBootstrap () {
                // Load basic include files to continue bootstrapping
                self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+               self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sclass_BaseFrameworkSystem.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
                self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
                self::loadInclude(new SplFileInfo(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR)));
 
index 2521e3c9f4e755dfe6bad2b3619691dcf650ac86..82d50bf964606d4882a619806f11fa96178122fc 100644 (file)
@@ -99,34 +99,6 @@ class FrameworkConfiguration implements Registerable {
                return self::$configInstance;
        }
 
-       /**
-        * Converts dashes to underscores, e.g. useable for configuration entries
-        *
-        * @param       $str    The string with maybe dashes inside
-        * @return      $str    The converted string with no dashed, but underscores
-        * @throws      NullPointerException    If $str is null
-        * @throws      InvalidArgumentException        If $str is empty
-        */
-       private final 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);
-
-               // Return converted string
-               return $str;
-       }
-
        /**
         * Checks whether the given configuration key is set
         *
@@ -178,7 +150,7 @@ class FrameworkConfiguration implements Registerable {
                }
 
                // Convert dashes to underscore
-               $configKey = $this->convertDashesToUnderscores($configKey);
+               $configKey = BaseFrameworkSystem::convertDashesToUnderscores($configKey);
 
                // Is a valid configuration key provided?
                if (!$this->isConfigurationEntrySet($configKey)) {
@@ -217,7 +189,7 @@ class FrameworkConfiguration implements Registerable {
                }
 
                // Cast to string
-               $configKey = $this->convertDashesToUnderscores($configKey);
+               $configKey = BaseFrameworkSystem::convertDashesToUnderscores($configKey);
 
                // Set the configuration value
                //* NOISY-DEBUG: */ print(__METHOD__ . ':configEntry=' . $configKey . ',configValue[' . gettype($configValue) . ']=' . $configValue . PHP_EOL);
@@ -261,7 +233,7 @@ class FrameworkConfiguration implements Registerable {
                }
 
                // Convert dashes to underscore
-               $configKey = $this->convertDashesToUnderscores($configKey);
+               $configKey = BaseFrameworkSystem::convertDashesToUnderscores($configKey);
 
                // Is the configuration key there?
                if (!$this->isConfigurationEntrySet($configKey)) {
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);