From: Roland Häder Date: Sat, 18 Feb 2023 02:10:06 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1287590bb4dff94252b1c45f320d93ce65eb5495;hp=c20af2b1b05f92040a8cfabfb1d0c5cd2771f7c5;p=core.git Continued: - changed to generic exceptions - introduced EXCEPTION_BAD_METHOD_CALL exception code --- diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index a22be776..b4e203a0 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -1124,7 +1124,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { // No, then abort here - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found.', $keyGroup, $subGroup)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Return it @@ -1283,7 +1283,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (($forceInit === false) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) { // Already initialized - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s already initialized.', $keyGroup, $subGroup)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s already initialized.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Initialize it @@ -1315,7 +1315,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (($forceInit === false) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) { // Already initialized - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s already initialized.', $keyGroup, $subGroup, gettype($key), $key)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s already initialized.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Initialize it @@ -1351,7 +1351,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (($forceInit === false) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) { // Already initialized - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s,element[%s]=%s already initialized.', $keyGroup, $subGroup, gettype($key), $key, gettype($element), $element)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s,element[%s]=%s already initialized.', $keyGroup, $subGroup, gettype($key), $key, gettype($element), $element), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Initialize it @@ -1458,7 +1458,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Not found - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Then "pop" it @@ -1494,7 +1494,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Not found - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Then "shift" it @@ -1522,7 +1522,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!isset($this->genericArray[$keyGroup])) { // Not found - throw new BadMethodCallException(sprintf('keyGroup=%s not found.', $keyGroup)); + throw new BadMethodCallException(sprintf('keyGroup=%s not found.', $keyGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Then count it @@ -1553,7 +1553,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { // Abort here - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found.', $keyGroup, $subGroup)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Then count it @@ -1588,10 +1588,10 @@ Loaded includes: throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Abort here - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) { // Not valid - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s is not a valid key/sub group.', $keyGroup, $subGroup)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s is not a valid key/sub group.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Then count it @@ -1618,7 +1618,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!isset($this->genericArray[$keyGroup])) { // Then abort here - throw new BadMethodCallException(sprintf('keyGroup=%s not found', $keyGroup)); + throw new BadMethodCallException(sprintf('keyGroup=%s not found', $keyGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Return it @@ -1650,7 +1650,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) { // Then abort here - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found', $keyGroup)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found', $keyGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Set value here @@ -1681,7 +1681,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { // Then abort here - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Return it @@ -1751,7 +1751,7 @@ Loaded includes: throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { // Then abort here - throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s,element[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key, gettype($element), $element)); + throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s,element[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key, gettype($element), $element), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Return it diff --git a/framework/main/classes/criteria/class_BaseCriteria.php b/framework/main/classes/criteria/class_BaseCriteria.php index b9e86065..4c59aef6 100644 --- a/framework/main/classes/criteria/class_BaseCriteria.php +++ b/framework/main/classes/criteria/class_BaseCriteria.php @@ -670,7 +670,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType)); } elseif (!$this->isValidGenericArrayGroup('criteria', $criteriaType)) { // Not intialized yet - throw new BadMethodCallException(sprintf('Method cannot be invoked before criteriaType=%s is initialized!', $criteriaType)); + throw new BadMethodCallException(sprintf('Method cannot be invoked before criteriaType=%s is initialized!', $criteriaType), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Initialize the key diff --git a/framework/main/classes/feature/class_FrameworkFeature.php b/framework/main/classes/feature/class_FrameworkFeature.php index f3597d2d..58610e40 100644 --- a/framework/main/classes/feature/class_FrameworkFeature.php +++ b/framework/main/classes/feature/class_FrameworkFeature.php @@ -11,6 +11,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils; // Import SPL stuff +use \BadMethodCallException; use \InvalidArgumentException; /** @@ -164,15 +165,23 @@ class FrameworkFeature extends BaseFrameworkSystem { * @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( diff --git a/framework/main/classes/helper/class_BaseHelper.php b/framework/main/classes/helper/class_BaseHelper.php index 413655db..055420e0 100644 --- a/framework/main/classes/helper/class_BaseHelper.php +++ b/framework/main/classes/helper/class_BaseHelper.php @@ -78,11 +78,10 @@ abstract class BaseHelper extends BaseFrameworkSystem { private $totalCounter = 0; // Exception constants - const EXCEPTION_GROUP_NOT_OPENED = 0x1e3; - const EXCEPTION_GROUP_ALREADY_FOUND = 0x1e4; - const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e5; - const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e6; - const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e7; + const EXCEPTION_GROUP_NOT_OPENED = 0x1e0; + const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e1; + const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e2; + const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e3; /** * Protected constructor @@ -315,7 +314,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "groupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (isset($this->groups[$groupId])) { // Then throw an exception here - throw new BadMethodCallException(sprintf('[%s:%d]: groupId=%s is already opened.', $this->__toString(), $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND); + throw new BadMethodCallException(sprintf('[%s:%d]: groupId=%s is already opened.', $this->__toString(), $groupId), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif (empty($content)) { // Throw IAE throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); diff --git a/framework/main/classes/iterator/file/class_FileIterator.php b/framework/main/classes/iterator/file/class_FileIterator.php index 7ebae5f0..da4ca9b3 100644 --- a/framework/main/classes/iterator/file/class_FileIterator.php +++ b/framework/main/classes/iterator/file/class_FileIterator.php @@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Iterator\File; // Import framework stuff use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Iterator\BaseIterator; use Org\Mxchange\CoreFramework\Traits\File\BinaryFileTrait; @@ -79,7 +80,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!'); if (!$this->valid()) { // Throw BMCE - throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?'); + throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Call file instance @@ -101,7 +102,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!'); if (!$this->valid()) { // Throw BMCE - throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?'); + throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Get key from file instance diff --git a/framework/main/classes/iterator/registry/class_RegistryIterator.php b/framework/main/classes/iterator/registry/class_RegistryIterator.php index f8762d9a..6efdb0f4 100644 --- a/framework/main/classes/iterator/registry/class_RegistryIterator.php +++ b/framework/main/classes/iterator/registry/class_RegistryIterator.php @@ -278,10 +278,10 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE))); if (!$this->valid()) { // Bad method call! - throw new BadMethodCallException(sprintf('this->key[%s]=%s is no longer valid, but method was called.', gettype($this->key()), $this->key())); + throw new BadMethodCallException(sprintf('this->key[%s]=%s is no longer valid, but method was called.', gettype($this->key()), $this->key()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ((count($this->registryKeys['generic']) == 0) && (count($this->registryKeys['instance']) == 0)) { // Both arrays are empty - throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.'); + throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Default is not valid @@ -305,7 +305,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: isNextValid=%d', $this->key(), intval($isNextValid))); if (!$isNextValid) { // Throw exception - throw new BadMethodCallException(sprintf('this->key=%s is last key in this iteration. Forgot to invoke valid() before?', $this->key())); + throw new BadMethodCallException(sprintf('this->key=%s is last key in this iteration. Forgot to invoke valid() before?', $this->key()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ($registryType == 'invalid') { // Not changed! throw new UnexpectedValueException('registryType has not been changed.'); @@ -330,10 +330,10 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE))); if (array_search($this->key(), $this->getRegistryKeys()) === 0) { // rewind() cannot rewind first entry! - throw new BadMethodCallException(sprintf('this->key=%s is already first element, but method was called.', $this->key())); + throw new BadMethodCallException(sprintf('this->key=%s is already first element, but method was called.', $this->key()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ((count($this->registryKeys['generic']) == 0) && (count($this->registryKeys['instance']) == 0)) { // Both arrays are empty - throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.'); + throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Get first array element ... diff --git a/framework/main/classes/stacker/class_BaseStacker.php b/framework/main/classes/stacker/class_BaseStacker.php index 3480ddb7..8bbb1a8f 100644 --- a/framework/main/classes/stacker/class_BaseStacker.php +++ b/framework/main/classes/stacker/class_BaseStacker.php @@ -34,12 +34,6 @@ use \InvalidArgumentException; * along with this program. If not, see . */ abstract class BaseStacker extends BaseFrameworkSystem { - // Exception codes - const EXCEPTION_STACKER_ALREADY_INITIALIZED = 0x050; - const EXCEPTION_STACKER_IS_FULL = 0x051; - const EXCEPTION_NO_STACKER_FOUND = 0x052; - const EXCEPTION_STACKER_IS_EMPTY = 0x053; - /** * Array "caches" configuration entries for saving "expensive" method * invocations @@ -74,7 +68,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (($forceReInit === false) && ($this->isStackInitialized($stackerName))) { // Then throw the exception - throw new BadMethodCallException(array($this, $stackerName, $forceReInit), self::EXCEPTION_STACKER_ALREADY_INITIALIZED); + throw new BadMethodCallException(array($this, $stackerName, $forceReInit), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Initialize the given stack and "cache" configuration entry @@ -149,7 +143,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // So, is the stack full? @@ -176,7 +170,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // So, is the stack empty? @@ -203,7 +197,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now, count the array of entries @@ -232,10 +226,10 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ($this->isStackFull($stackerName)) { // Stacker is full - throw new FullStackerException([$this, $stackerName, $value], self::EXCEPTION_STACKER_IS_FULL); + throw new BadMethodCallException(sprintf('stackerName=%s is full but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now add the value to the stack @@ -262,10 +256,10 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Calculate last index @@ -296,10 +290,10 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now get the first value @@ -327,10 +321,10 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException(sprintf('stackerName=%s is empty but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above @@ -358,10 +352,10 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif (!$this->isStackInitialized($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above diff --git a/framework/main/classes/stacker/fifo/class_FiFoStacker.php b/framework/main/classes/stacker/fifo/class_FiFoStacker.php index c19b614a..0e5fa9cd 100644 --- a/framework/main/classes/stacker/fifo/class_FiFoStacker.php +++ b/framework/main/classes/stacker/fifo/class_FiFoStacker.php @@ -64,7 +64,7 @@ class FiFoStacker extends BaseStacker implements Stackable { * @param $value Value to push on it * @return void * @throws InvalidArgumentException If a parameter is invalid - * @throws StackerFullException If the stack is full + * @throws BadMethodCallException If the stack is full */ public function pushNamed (string $stackerName, $value) { // Validate parameter diff --git a/framework/main/classes/stacker/file/class_BaseFileStack.php b/framework/main/classes/stacker/file/class_BaseFileStack.php index 5a0fd38c..ac3c6051 100644 --- a/framework/main/classes/stacker/file/class_BaseFileStack.php +++ b/framework/main/classes/stacker/file/class_BaseFileStack.php @@ -322,7 +322,7 @@ abstract class BaseFileStack extends BaseStacker { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($this->isStackFull($stackerName)) { // Stacker is full - throw new FullStackerException([$this, $stackerName, $value], self::EXCEPTION_STACKER_IS_FULL); + throw new BadMethodCallException(sprintf('stackerName=%s is full but method call.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif (is_resource($value) || is_object($value)) { // Not wanted type throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($value))); @@ -360,7 +360,7 @@ abstract class BaseFileStack extends BaseStacker { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now get the last value @@ -388,7 +388,7 @@ abstract class BaseFileStack extends BaseStacker { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now get the first value @@ -416,7 +416,7 @@ abstract class BaseFileStack extends BaseStacker { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above @@ -440,7 +440,7 @@ abstract class BaseFileStack extends BaseStacker { throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($this->isStackEmpty($stackerName)) { // Throw an exception - throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY); + throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above diff --git a/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php b/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php index 30344ab8..8d581e42 100644 --- a/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php +++ b/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php @@ -82,7 +82,7 @@ class FiFoFileStack extends BaseFileStack implements StackableFile, Calculatable * @param $value Value to push on it * @return void * @throws InvalidArgumentException If a parameter is invalid - * @throws StackerFullException If the stack is full + * @throws BadMethodCallException If the stack is full */ public function pushNamed (string $stackerName, $value) { // Validate parameter diff --git a/framework/main/classes/stacker/filo/class_FiLoStacker.php b/framework/main/classes/stacker/filo/class_FiLoStacker.php index 79db9944..16e78b02 100644 --- a/framework/main/classes/stacker/filo/class_FiLoStacker.php +++ b/framework/main/classes/stacker/filo/class_FiLoStacker.php @@ -63,7 +63,7 @@ class FiLoStacker extends BaseStacker implements Stackable { * @param $value Value to push on it * @return void * @throws InvalidArgumentException If a parameter is invalid - * @throws StackerFullException If the stack is full + * @throws BadMethodCallException If the stack is full */ public function pushNamed (string $stackerName, $value) { // Validate parameter diff --git a/framework/main/interfaces/stacker/class_Stackable.php b/framework/main/interfaces/stacker/class_Stackable.php index 7e61eb42..a282544c 100644 --- a/framework/main/interfaces/stacker/class_Stackable.php +++ b/framework/main/interfaces/stacker/class_Stackable.php @@ -34,7 +34,7 @@ interface Stackable extends FrameworkInterface { * @param $stackerName Name of the stacker * @param $value Value to push on it * @return void - * @throws StackerFullException If the stacker is full + * @throws BadMethodCallException If the stacker is full */ function pushNamed (string $stackerName, $value);