]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/feature/class_FrameworkFeature.php
Continued:
[core.git] / framework / main / classes / feature / class_FrameworkFeature.php
index 1bcec3f8822eb30bab2181bd2e3c7bd6ebe5924b..db57e5cc6759c3bd90bb775397c411eb0340c5e6 100644 (file)
@@ -9,6 +9,9 @@ use Org\Mxchange\CoreFramework\Loader\NoClassException;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 
+// Import SPL stuff
+use \InvalidArgumentException;
+
 /**
  * The general feature management class. No instance is needed as this class
  * has only public methods that are static.
@@ -73,8 +76,16 @@ class FrameworkFeature extends BaseFrameworkSystem {
         *
         * @param       $featureName    Name of the feature to be checked
         * @return      $isEnabled              Whether the given feature is enabled
+        * @throws      InvalidArgumentException        If a parameter is invalid
         */
        public static function isFeatureEnabled (string $featureName) {
+               // Check parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
+               if (empty($featureName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "featureName" is empty');
+               }
+
                // Is the cache set?
                if (!isset(self::$enabledFeatures[$featureName]['is_enabled'])) {
                        // Generate config key
@@ -85,6 +96,7 @@ class FrameworkFeature extends BaseFrameworkSystem {
                }
 
                // Return "cached" status
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: is_enabled[%s]=%d - EXIT!', $featureName, intval(self::$enabledFeatures[$featureName]['is_enabled'])));
                return self::$enabledFeatures[$featureName]['is_enabled'];
        }
 
@@ -97,10 +109,17 @@ class FrameworkFeature extends BaseFrameworkSystem {
         *
         * @param       $featureName    Name of the feature to be checked on availability
         * @return      $isAvailable    Whether the given feature is available
+        * @throws      InvalidArgumentException        If a parameter is invalid
         */
        public static function isFeatureAvailable (string $featureName) {
-               // Is the cache set?
+               // Check parameter
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
+               if (empty($featureName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "featureName" is empty');
+               }
+
+               // Is the cache set?
                if (!isset(self::$enabledFeatures[$featureName]['is_available'])) {
                        // Default is not available
                        self::$enabledFeatures[$featureName]['is_available'] = false;