- public final function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = 'default') {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!');
-
- // Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue)));
+ public final function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s--CRITERIA: criteriaKey=%s,criteriaValue[]=%s$criteriaValue,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaType));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty');
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ } elseif (is_array($criteriaValue) || is_bool($criteriaValue) || is_object($criteriaValue) || is_resource($criteriaValue)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($criteriaValue)));
+ } elseif (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty');
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType));
+ }