- public static function callFeature ($featureName, $featureMethod, array $args = NULL) {
- /*
- * Please make sure that isFeatureAvailable() has been called and it has
- * returned true before calling this method.
- */
- assert(self::isFeatureAvailable($featureName));
+ public static function callFeature (string $featureName, string $featureMethod, array $args = NULL) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: featureName=%s,featureMethod=%s,args[]=%s - CALLED!', $featureName, $featureMethod, gettype($args)));
+ if (empty($featureName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($featureMethod)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureMethod" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!self::isFeatureAvailable($featureName)) {
+ // Throw BMCE
+ throw new BadMethodCallException(sprintf('Feature "%s" is not available but method "%s" should be invoked.', $featureName, $featureMethod), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ }