@param string $fieldName
@param mixed $valueToTest
@param int $exceptionCode

@throws InvalidValueException
190111
protected function ensureIsBoolean($fieldName, $valueToTest, $exceptionCode = 0)
    {
        if (!is_bool($valueToTest)) {
            $type = is_object($valueToTest) ? get_class($valueToTest) : gettype($valueToTest);
            $message = sprintf('%s is not a boolean, got "%s"', $fieldName, $type);
            throw new InvalidValueException($message, $exceptionCode);
        }
    }
258499
public function set($itemName, $itemValue)
    {
        list($validationResult, $message) = IniParser::i()->validateItemName($itemName);
        if (false === $validationResult)
        {
            throw new InvalidDataException($message);
        }
        $this->contents[$itemName] = IniParser::i()->itemValuetoStringRepresentation($itemValue);

        return $this;
    }
110742
public function processFormData(array $valuelist)
    {
        if ($valuelist) {
            $date_str = implode(" ", $valuelist);
            try {
                $this->data = Carbon::createFromFormat($this->carbon_format, $date_str)->startOfDay();
            } catch (\Exception $e) {
                $this->data = null;
                // Do not create a process error if this is an optional field
                if (!empty($date_str) && !$this->flags->optional) {
                    throw new ValueError("Not a valid date value");
                }
            }
        }
    }
140534
protected function convertValueFromStorage($valueName, $value) {
    // filter values according to type
    if ($this->hasAttribute($valueName)) {
      $type = $this->getAttribute($valueName)->getType();
      // integer
      if (strpos(strtolower($type), 'int') === 0) {
        $value = (strlen($value) == 0) ? null : intval($value);
      }
    }
    return $value;
  }
547372
public function assertIsArrayAndNotEmpty($value, $message='%s must not be an empty Array', $exception='Asserts')
    {
        if (isset($value) === false || is_array($value) === false || (is_array($value) && count($value) <= 0)) {
            $this->throwException($exception, $message, $value);
        }
    }
1147074
protected function ensureIsUrl($fieldName, $valueToTest, $exceptionCode = 0)
    {
        $regex = '@^(https?|ftp)://[^\s/$.?#].[^\s]*$@iS';

        if (preg_match($regex, $valueToTest) !== 1) {
            $message = sprintf('%s is not a matching url, got "%s"', $fieldName, $valueToTest);
            throw new InvalidValueException($message, $exceptionCode);
        }
    }
1161250
public function push($fieldName, $value)
    {
        $oldValue = $this->get($fieldName);

        // check if old value is list or sub document
        // on sub document throw exception
        if (is_array($oldValue)) {
            $isSubDocument = (array_keys($oldValue) !== range(0, count($oldValue) - 1));
            if ($isSubDocument) {
                throw new InvalidOperationException(sprintf(
                    'The field "%s" must be an array but is of type Object',
                    $fieldName
                ));
            }
        }

        // prepare new value
        $value = Structure::prepareToStore($value);

        // field not exists
        if (!$oldValue) {
            if ($this->getId()) {
                $this->operator->push($fieldName, $value);
            }
            $value = array($value);
        } // field already exist and has single value
        elseif (!is_array($oldValue)) {
            $value = array_merge((array) $oldValue, array($value));
            if ($this->getId()) {
                $this->operator->set($fieldName, $value);
            }
        } // field exists and is array
        else {
            if ($this->getId()) {
                $setValue = $this->operator->get('$set', $fieldName);
                if ($setValue) {
                    $setValue[] = $value;
                    $this->operator->set($fieldName, $setValue);
                } else {
                    $this->operator->push($fieldName, $value);
                }
            }
            $value = array_merge($oldValue, array($value));
        }

        // update local data
        parent::set($fieldName, $value);

        return $this;
    }
253160
public function getFilter(string $code): FilterInterface
    {
        if (empty($this->filters[$code])) {
            throw new UnexpectedValueException("No filter with code : {$code} for query handler {$this->code}");
        }

        return $this->filters[$code];
    }
860666
public static void assertXpathEvaluatesTo(String expectedValue,
                                              String xpathExpression,
                                              InputSource control)
        throws SAXException, IOException,
               XpathException {
        Document document = XMLUnit.buildControlDocument(control);
        assertXpathEvaluatesTo(expectedValue, xpathExpression, document);
    }
924356
public static function throwCurlException($errorMessage, $errorCode)
    {
        $exception = new Adyen_Payment_Exception($errorMessage, $errorCode);
        self::logException($exception);

        throw $exception;
    }
118608
public function setValueType($valueType)
    {
        if (in_array($valueType, ParamType::asArray(), true) === true) {
            $this->valueType = $valueType;
        } else {
            $msg = "The 'valueType' argument must be a value from the ParamType enumeration, '" . gettype($valueType) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
935506
protected function checkThrowable($throwable, $expectedClass, $expectedMsg, $expectedCode)
    {
        if (!($throwable instanceof $expectedClass)) {
            $this->fail(sprintf(
                "Exception of class '$expectedClass' expected to be thrown, but class '%s' was caught",
                get_class($throwable)
            ));
        }

        if (null !== $expectedMsg && $throwable->getMessage() !== $expectedMsg) {
            $this->fail(sprintf(
                "Exception of class '$expectedClass' expected to have message '$expectedMsg', but actual message was '%s'",
                $throwable->getMessage()
            ));
        }

        if (null !== $expectedCode && $throwable->getCode() !== $expectedCode) {
            $this->fail(sprintf(
                "Exception of class '$expectedClass' expected to have code '$expectedCode', but actual code was '%s'",
                $throwable->getCode()
            ));
        }

        $this->assertTrue(true); // increment assertion counter
    }
420126
private function checkArrayStructure(array $invalidCodes, int $searchPos): void
    {
        // Rename the var to get more readable code.
        $remainingInvalidCodes = $invalidCodes;
        unset($invalidCodes);

        foreach ($remainingInvalidCodes as $nextInvalidCodeIndex => $nextInvalidCode) {
            $foundTokenPos = TokenHelper::findNextEffective($this->getFile(), $searchPos);
            $foundToken = $this->tokens[$foundTokenPos];

            // We can stop the search, if there is no invalid code.
            if ($foundToken['code'] !== $nextInvalidCode) {
                break;
            }

            // Check the next possible token
            $searchPos = $foundTokenPos + 1;
            unset($remainingInvalidCodes[$nextInvalidCodeIndex]);
        }

        $matchedEveryInvalidCode = !$remainingInvalidCodes;

        $this->file->recordMetric(
            $searchPos,
            'Invalid array comparison',
            $matchedEveryInvalidCode ? 'yes' : 'no'
        );

        if ($matchedEveryInvalidCode) {
            throw (new CodeError(static::CODE_EMPTY_ARRAY, self::MESSAGE_EMPTY_ARRAY, $searchPos));
        }
    }
765644
public static void writeValueToBeanField(Object entityBean, String fieldName, Object value) {
		Method writeMethod = ClassCacheUtils.getClassFieldWriteMethod(entityBean.getClass(), fieldName);
		if (writeMethod == null) {
			throw new DialectException("Can not find Java bean read method '" + fieldName + "'");
		} else
			try {
				writeMethod.invoke(entityBean, value);
			} catch (Exception e) {
				throw new DialectException("FieldName '" + fieldName + "' can not write with value '" + value + "'", e);
			}
	}
55017
public function assertIsNumericAndNonZero($value, $message='%s must be a number and not 0', $exception='Asserts')
    {
        if (is_numeric($value) === false || floatval($value) <= 0) {
            $this->throwException($exception, $message, $value);
        }
    }
791113
public function assertIsTrue($value, $message='%s must be True', $exception='Asserts')
    {
        if (is_bool($value) === false || $value !== true) {
            $this->throwException($exception, $message, $value);
        }
    }
1213245
protected function ensureMatchesPattern($fieldName, $regex, $valueToTest, $exceptionCode = 0)
    {
        if (preg_match($regex, $valueToTest) !== 1) {
            $message = sprintf('%s does not match the regular expression "%s", got "%s"', $fieldName, $regex, $valueToTest);
            throw new EnsureMatchesPatternException($message, $exceptionCode);
        }
    }