@param mixed $value
@param array $options

@throws \Exception

@return string
766840
public function renderValue($value, array $options = []): string
    {
        $resolver = new OptionsResolver();
        $this->configureOptions($resolver);
        $options = $resolver->resolve($options);

        if ($value instanceof \DateTimeInterface) {
            if (null !== $options['date_format']) {
                return (string) $value->format($options['date_format']);
            }
            if ($value->format('H:i') === '00:00') {
                $options['time_type'] = \IntlDateFormatter::NONE;
            }
            $dateFormatter = new \IntlDateFormatter(
                $this->translator->getLocale(),
                $options['date_type'],
                $options['time_type']
            );

            return (string) $dateFormatter->format($value);
        }
        if (\is_int($value)) {
            return (string) $value;
        }
        if (\is_float($value)) {
            if (null !== $options['decimals'] || null !== $options['dec_point'] || null !== $options['thousands_sep']) {
                return number_format(
                    $value,
                    $options['decimals'] ?: 2,
                    $options['dec_point'] ?: '.',
                    $options['thousands_sep'] ?: ','
                );
            }
            $numberFormatter = new \NumberFormatter($this->translator->getLocale(), $options['number_format']);

            return (string) $numberFormatter->format($value);
        }
        if (\is_iterable($value)) {
            $items = [];
            /** @noinspection ForeachSourceInspection */
            foreach ($value as $key => $item) {
                $rendered = $this->renderValue($item, $options);
                if (!is_numeric($key)) {
                    $rendered = $key.$options['key_value_separator'].$rendered;
                }
                $items[] = $rendered;
            }

            return implode($options['array_glue'], $items);
        }
        if (\is_bool($value)) {
            if ($options['bool_use_translator']) {
                return (string) $this->translator->trans(
                    $value ? $options['bool_true'] : $options['bool_false']
                );
            }

            return $value ? $options['bool_true'] : $options['bool_false'];
        }

        return (string) $value;
    }
678479
public function filter($value, $options = [])
    {
        if ($this->getPattern() == null) {
            $ex = new \Exception(get_class($this) . ' does not have a valid MatchPattern set.');
            throw $ex;
        }

        return preg_replace($this->getPattern(), $this->getReplacement(), $value);
    }
448547
public static function encode($value, $options = 0): string
	{
		$flags = \PHP_VERSION_ID >= 50400
			? (\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | ($options & self::PRETTY
					? \JSON_PRETTY_PRINT
					: 0))
			: 0;

		if (\PHP_VERSION_ID < 50500) {
			$json = Callback::invokeSafe('json_encode', [$value, $flags], static function ($message) { // needed to receive 'recursion detected' error

				throw new JsonException($message);
			});
		} else {
			$json = \json_encode($value, $flags);
		}

		$error = \json_last_error();

		if ($error) {
			$message = static::$messages[$error] ?? (\PHP_VERSION_ID >= 50500 ? \json_last_error_msg() : 'Unknown error');

			throw new JsonException($message, $error);
		}

		$json = \str_replace(["\xe2\x80\xa8", "\xe2\x80\xa9"], ['\u2028', '\u2029'], $json);

		return $json;
	}
1275054
public static function enum(&$value, $options = ['enum'=>[], 'strict'=>false, 'default'=>null])
    {
        if (isset($options['enum']) && is_array($options['enum']) && $options['enum'] != []) {
            $value = in_array($value, $options['enum'], isset($options['strict']) && $options['strict']) ?
                $value : (isset($options['default']) ?
                    $options['default'] : current($options['enum']));
        } else {
            $value = isset($options['default']) ? $options['default'] : null;
        }
        return $value;
    }
972190
public function escape($value, $method = null, array $options = []) {
		$defaults = ['escape' => true];
		$options += $defaults;

		if ($options['escape'] === false) {
			return $value;
		}
		if (is_array($value)) {
			return array_map([$this, __FUNCTION__], $value);
		}
		return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
	}
1175335
public static function string(&$value, $options = ['length'=>null, 'regex'=>null, 'default'=>null])
    {
        $value = htmlspecialchars(trim($value));
        self::processString($value, $options);
        return $value;
    }
821654
public function isValid($value = null, array $options = []): bool
    {
        if (\count($options) > 0) {
            $this->setOptions($options);
        }
        $this->setValue(\str_replace(' ', '', (string)$value));
        $this->errors = [];

        if ($this->options['country-code'] !== null) {
            $newValue = \preg_match('/^[A-Z]{2}/', $this->value)
                ? \preg_replace('/^[A-Z]{2}/', $this->options['country-code'], $this->value)
                : $this->options['country-code'].$this->value;

            $this->setValue($newValue);
        }

        $countryCode = \substr($this->value, 0, 2);
        if (!\array_key_exists($countryCode, $this->patterns)) {
            throw new DomainException('Unsopported country code: '.$countryCode);
        }
        if ($this->options['allow-non-sepa'] === false && !\in_array($countryCode, $this->sepaCountries)) {
            $exMsg = 'Countries outside the Single Euro Payments Area (SEPA) are not supported';
            throw new DomainException($exMsg);
        }

        if (!\preg_match('/^'.$this->patterns[$countryCode].'$/', $this->value)) {
            $this->setError(self::VALIDATOR_ERROR_IBAN_INCORRECT_FORMAT);
            return false;
        }

        return $this->validateIban();
    }
303191
protected function validateOptions($name, $value, $options)
    {
        if (!in_array($value, $options)) {
            throw new \Exception(
                $name . ' must be one of: ' . implode(', ', $options)
            );
        }
    }
928227
public static function encode(
        $value,
        $options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION
    ) {
        $json = \json_encode($value, $options);
        if (JSON_ERROR_NONE !== ($error = \json_last_error())) {
            throw new JsonException(\json_last_error_msg(), $error);
        }

        return $json;
    }
783659
public function base64($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return base64_encode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return base64_decode($value);
        }

        return $value;
    }
1232838
protected function unpack($field, $value, $options) {
        switch ($options['type']) {
            case 'int':
                return intval($value);
            case 'float':
                return floatval($value);
            case 'list':
                if ($value) {
                    return @explode(',', $value);
                } else {
                    return [];
                }
            case 'array':
            case 'json':
                $value = @json_decode($value, true);

                return $value ? $value : [];
            case 'date':
                return $value ? date('Y-m-d', $value) : '';
            case 'datetime':
                return $value ? date('Y-m-d H:i:s', $value) : '';
            case 'bool':
                return boolval($value) ? 1 : 0;
            default:
                return $value;
        }
    }
848495
public function serialize($value, array $options=[])
    {

        if (!is_string($value)) {
            throw new UnexpectedValueException('I can only work with strings, not ' . Type::of($value));
        }

        return $value;

    }
936086
protected function findData($value, array $options)
    {
        /** @var FamilyInterface $family */
        $family = $options['family'];
        /** @var AttributeInterface $attribute */
        $attribute = $options['attribute'];
        /** @var DataRepository $repository */
        $repository = $options['repository'];

        $data = $repository->findByUniqueAttribute($family, $attribute, $value);
        if (null === $data && !$options['ignore_missing']) {
            $msg = "Missing entity for family {$family->getCode()} and";
            $msg .= " attribute {$attribute->getCode()} with value '{$value}'";
            throw new \UnexpectedValueException($msg);
        }

        return $data;
    }
157380
protected function mapValuesToOptions(array $value, array $options)
    {
        $result = [];
        foreach ($value as $key) {
            $result[] = $this->mapValueToOption($key, $options);
        }
        return $result;
    }
1363663
public static function convert($value, $options = self::VAR_STRING)
    {
        $options = (int)$options;

        if ($options & self::VAR_STRING && !empty($value)) {
            return trim(Filter::stripQuotes($value));
        }

        if ($options & self::VAR_FLOAT) {
            return Filter::float($value, 12);
        }

        if ($options & self::VAR_INT) {
            return Filter::int($value);
        }

        if ($options & self::VAR_BOOL || $options & self::VAR_NULL) {
            if (null === $value || 'null' === strtolower(trim($value))) {
                return null;
            }

            return Filter::bool($value);
        }

        return (string)$value;
    }
385591
protected function _getFindUserQuery($value, $options) {
		if (is_string($value) && $this->_table->hasFinder($value)) {
			$query = $this->_table->find($value, ['getUserOptions' => $options]);
		} else {
			$query = $this->_table->find();
		}

		if (is_array($options['field'])) {
			foreach ($options['field'] as $field) {
				$query->where([
					'OR' => [$field => $value]
				]);
			}

		return $query;
	}

		return $query->where([$options['field'] => $value]);
	}
1097121
private function convert($value, $type, array $options, array $convertCallbacks)
    {
        if (null === $value) {
            return ParameterModel::TYPE_STRING === $type ? '' : null;
        }
        if (!isset($convertCallbacks[$type])) {
            return $value;
        }

        $callback = $convertCallbacks[$type];

        return is_string($callback) ? $callback($value) : $callback($value, $options);
    }