private function validateValue($value, $type, $allowNull = false)
    {
        if (!is_numeric($value) && (!$allowNull || ($allowNull && $value !== null))) {
            throw new InvalidArgumentException(sprintf(
                'Given %s must be a numeric value.',
                $type
            ));
        }

        return $allowNull && $value === null
            ? $value
            : (float) $value;
    }