@param string $value
@param string $parameter

@return int|string|null
553141
protected function _validate_const($value, $parameter = null)
    {
        $context = $this->_context;

        $model = $context->model;
        $constants = $model::consts($parameter ?: $context->field);
        if (isset($constants[$value])) {
            return $value;
        } else {
            return ($r = array_search($value, $constants, true)) !== false ? $r : null;
        }
    }
269468
private function search(string $parameter, string $value): SeriesData
    {
        $options = [
            'query' => [
                $parameter => $value,
            ],
            'http_errors' => false
        ];

        $json = $this->client->performApiCallWithJsonResponse('get', '/search/series', $options);
        return ResponseHandler::create($json, ResponseHandler::METHOD_SEARCH_SERIES)->handle();
    }
1230667
public function param($param, $value, $type = null)
    {
        return $this->setParameter($param, $value, $type);
    }
524397
public function parameter($value)
    {

        // Validate whether the requested field is the
        // node id, in that case id(n) doesn't work as
        // a placeholder so we transform it to the id replacement instead.

        // When coming from a WHERE statement we'll have to pluck out the column
        // from the collected attributes.
        if(is_array($value) && isset($value['binding']))
        {
            $value = $value['binding'];
        }
        elseif (is_array($value) && isset($value['column']))
        {
            $value = $value['column'];
        }
        elseif ($this->isExpression($value))
        {
            $value = $this->getValue($value);
        }

        $property = $this->getIdReplacement($value);

        if (strpos($property, '.') !== false) $property = explode('.', $property)[1];

        return '{' . $property . '}';
    }
1319475
protected function getValue( $key, $value = null )
	{
		if( is_null( $value ) && isset( $this->args[$key] )) {
			$value = $this->args[$key];
		}
		return $value;
	}
315352
protected function isRequiredWith($value, $parameters)
    {
        if (!$this->allFailingRequired($parameters)) {
            return $this->isRequired($value);
        }

        return true;
    }
421547
public function bindValue($parameter, $value, $type = \PDO::PARAM_STR)
    {
        list($value, $type) = TypeUtility::convertToDatabase($value, $type, $this->connection->getPlatform());

        return $this->getDriverStatement()->bindValue($parameter, $value, $type);
    }
505159
public function whereHas($parameter, $value)
    {
        if (! $this->verify($parameter, $value)) {
            return true;
        }

        $this->search = $this->search
            ->whereHas($parameter, function ($query) use ($value) {
                $query->where('rbac_roles.id', $value);
            });
    }
953505
public function validateNotEmpty($parameter, $value)
    {
        if (!empty($value)) {
            return true;
        }

        $message = sprintf('Parameter: %s cannot be empty.', $parameter);

        throw new AdldapException($message);
    }
1163637
public function bind($parameter, $value, $type = null)
    {
        $this->statement->bindParam($parameter, $value, $this->driver->getPdoType($type, $value));
        return $this;
    }
806006
protected function validateDecimal($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        if (count($args) == 0) {
            throw new ValidatorConfigException("Validator 'decimal' must have argument in validator list for parameter {$parameter}");
        }

        $decimals = (int)$args[0];

        if ($decimals <= 0) {
            throw new ValidatorConfigException("Validator 'decimal' has invalid value which is lower or equal to zero; for parameter={$parameter}");
        }

        if ($decimals > 100) {
            throw new ValidatorConfigException("Validator 'decimal' can't have that large argument; parameter={$parameter}");
        }

        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if ($value === '') {
            return null;
        }

        if (!is_numeric($value)) {
            return Message::getMessage(Message::NUMERIC, [
                'param' => $parameter,
                'value' => $value
            ]);
        }

        $parts = explode('.', $value);

        if (count($parts) == 1) {
            return null; // value is not decimal, it's probably integer, so it's ok
        }

        $valueDecimals = $parts[1];

        if (strlen($valueDecimals) > $decimals) {
            return Message::getMessage(Message::DECIMAL, [
                'param' => $parameter,
                'value' => $value,
                'decimals' => $decimals
            ]);
        }

        return null;
    }
97607
public function isDateFormat($value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'date_format');

        if (!is_string($value) && !is_numeric($value)) {
            return false;
        }

        $date = DateTime::createFromFormat($parameters[0], $value);

        return $date && $date->format($parameters[0]) == $value;
    }
572865
public function geetParamTypeByValue($value)
	{
		switch(gettype($value))
		{
			case 'boolean':
				return PDO::PARAM_BOOL;
				break;
			case 'integer':
				return PDO::PARAM_INT;
				break;
			case 'NULL':
				return PDO::PARAM_NULL;
				break;
			default:
				return PDO::PARAM_STR;
				break;
		}
	}
933940
protected function _validate_exists($value, $parameter = null)
    {
        $context = $this->_context;

        if (!$value) {
            return $value;
        }
        $field = $context->field;
        if ($parameter) {
            $className = $parameter;
        } else {
            $modelName = get_class($context->model);
            if (preg_match('#^(.*)_id$#', $field, $match)) {
                $className = substr($modelName, 0, strrpos($modelName, '\\') + 1) . Text::camelize($match[1]);
                if (!class_exists($className)) {
                    $className = $this->alias->get('@ns.app') . '\\Models\\' . Text::camelize($match[1]);
                }
            } else {
                throw new InvalidValueException(['validate `:field` field failed: related model class name is not provided', 'field' => $field]);
            }
        }

        if (!class_exists($className)) {
            throw new InvalidValueException(['validate `:1` field failed: related `:2` model class is not exists.', $field, $className]);
        }

        /**
         * @var \ManaPHP\Model $model
         * @var \ManaPHP\Model $className
         */
        $model = new $className;
        return $className::exists([$model->getPrimaryKey() => $value]) ? $value : null;
    }
1333482
public function setParameter(string $parameter, string $value): self
    {
        $this->parameters[$parameter] = $value;

        return $this;
    }
985013
protected function parseParameter($value, ReflectionParameter $parameter) {
	    if (!$parameter->hasType()) {
	        return $value;
        }
        if ($parameter->getType() == 'int') {
	        return intval($value);
        }
        return $value;
    }
1036365
protected function _validate_range($value, $parameter)
    {
        if (preg_match('#^(-?[\.\d]+)-(-?[\d\.]+)$#', $parameter, $match)) {
            return $value >= $match[1] && $value <= $match[2] ? $value : null;
        } else {
            throw new InvalidValueException(['range validator `:parameter` parameters is not {min}-{max} format', 'parameter' => $parameter]);
        }
    }