// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Loader\NoClassException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
// Import SPL stuff
+use \BadMethodCallException;
use \InvalidArgumentException;
/**
//* 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');
+ throw new InvalidArgumentException('Parameter "featureName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Is the cache set?
//* 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');
+ throw new InvalidArgumentException('Parameter "featureName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Is the cache set?
* @param $featureMethod Method name of the feature's class
* @param $args Any arguments that should be handled over
* @return $return Anything the feature's method has returned
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws BadMethodCallException If this method has been invoked but the feature isn't available
* @throws FeatureMethodNotCallableException If the requested method cannot be called
*/
- 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.
- */
+ public static function callFeature (string $featureName, string $featureMethod, array $args = NULL) {
+ // Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s,featureMethod=%s,args[]=%s - CALLED!', $featureName, $featureMethod, gettype($args)));
- assert(self::isFeatureAvailable($featureName));
+ 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);
+ }
// Array for call-back
$callable = array(