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.
*
* @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
}
// 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'];
}
*
* @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;