{@inheritdoc}

@param string $string
@param array $options (optional)

@return mixed
487567
public function deserialize($string, array $options=[])
    {
        if (!is_string($string)) {
            throw new UnexpectedValueException('I can only work with strings, not ' . Type::of($string));
        }

        return $string;
    }
1205786
public function slugify($string, $options = null)
    {
        // BC: the second argument used to be the separator
        if (is_string($options)) {
            $separator            = $options;
            $options              = [];
            $options['separator'] = $separator;
        }

        $options = array_merge($this->options, (array) $options);

        // Add a custom ruleset without touching the default rules
        if (isset($options['ruleset'])) {
            $rules = array_merge($this->rules, $this->provider->getRules($options['ruleset']));
        } else {
            $rules = $this->rules;
        }

        $string = ($options['strip_tags'])
            ? strip_tags($string)
            : $string;

        $string = strtr($string, $rules);
        unset($rules);

        if ($options['lowercase'] && !$options['lowercase_after_regexp']) {
            $string = mb_strtolower($string);
        }

        $string = preg_replace($options['regexp'], $options['separator'], $string);

        if ($options['lowercase'] && $options['lowercase_after_regexp']) {
            $string = mb_strtolower($string);
        }

        return ($options['trim'])
            ? trim($string, $options['separator'])
            : $string;
    }
159240
public static function get($url, $query = [], $options = [])
    {
        $options['query'] = $query;
        return self::doRequest('get', $url, $options);
    }
1217040
public static function toQueryString($options = array())
    {
        $temp = array();
        uksort($options, 'strnatcasecmp');
        foreach ($options as $key => $value) {
            if (is_string($key) && !is_array($value)) {
                $temp[] = rawurlencode($key) . '=' . rawurlencode($value);
            }
        }
        return implode('&', $temp);
    }
906882
public function checkbox($options)
    {

        if (is_string($options)) {
            $options = ['class' => $options];
        }

        if (!Arr::has($options, 'type')) {
            Arr::set($options, 'type', 'checkbox');
        }

        return $this->input($options);
    }
249733
public function deserialize(array $data, Options $options = null)
    {
        if (empty($options)) {
            $options = $this->optionsRepo->findOneBy(['id' => $data['id']]);
        }
        if (empty($options)) {
            $options = new Options();
        }
        if (isset($data['user'])) {
            $user = isset($data['user']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['user']['id']]) : null;
            $options->setUser($user);
        }
        if (isset($data['data'])) {
            $options->setOptions($data['data']);
        }

        return $options;
    }
1118186
public function provide($data = null, array $options = [])
    {
        // TODO: need to handle this better, type-casting to string will produce errors
        $result = (string)$data;

        if (empty($result)) {
            return $result;
        }

        // Sanitize
        $result = filter_var($result, FILTER_SANITIZE_STRING);
        if ($result === false) {
            // If you find a case where FILTER_SANITIZE_STRING fails, add
            // a unit test to StringRendererTest/PlainRendererTest and
            // remove annotations here.
            // @codeCoverageIgnoreStart
            throw new InvalidArgumentException("Failed to sanitize string");
            // @codeCoverageIgnoreEnd
        }

        return $result;
    }
845604
public function jsonDecode($string, $assoc = false, $depth = 512, $options = 0)
    {
        return json_decode($string, $assoc, $depth, $options);
    }
612112
private function getOption($option, array $options)
    {
        return isset($options[$option]) ? $options[$option] : $this->$option;
    }
321287
public function open($options = [])
    {
        if (is_string($options)) {
            $options = ['class' => $options];
        }

        $open = new Open($this->expression('open'), $options, $this->csrf, $this);
        return $open;
    }
1169267
protected function encode($data, $options = 0)
    {
        // Check is already json string.
        if (is_string($data) && strlen($data) >= 1) {
            $firstChar = $data[0];

            if (in_array($firstChar, ['[', '{', '"'])) {
                return $data;
            }
        }

        // Clear json_last_error()
        json_encode(null);

        $json = json_encode($data, $options);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \UnexpectedValueException(sprintf('JSON encode failure: %s', json_last_error_msg()));
        }

        return $json;
    }
814303
private function simpleGet($url, array $options = [])
    {
        return (array) \GuzzleHttp\json_decode(
          $this->getConnector()
               ->getClient()
               ->request('get', $url, $options)
               ->getBody()
               ->getContents(),
          true
        );
    }
273363
public static function fromString($string, Translations $translations, array $options = [])
    {
        $options += static::$options;

        $functions = new JsFunctionsScanner($string);
        $functions->saveGettextFunctions($translations, $options);
    }
95801
public function parse($string)
    {
        if (! $this->isSupports($string)) throw new \InvalidArgumentException('invalid string.');

        $define = new OptionDefine();
        preg_match($this->regexp_option, $string, $matches);

        // optional | required
        if ($matches[1] === 'require') $define->required();

        // long-name
        $define->setName($this->pickName($matches[2]));
        
        // short-name
        $define->setShortName($this->pickShortName($matches[2]));

        // defalt value
        $define->setDefault($this->pickValue($define, $matches[2]));
        
        // description
        $define->setDescription($this->pickDescription($matches));

        return $define;
    }
275618
protected static function mcryptEncrypt($key, $string, $options)
	{
		if ($options['rand_src'] == MCRYPT_RAND) {
			srand();
		}
		$iv	= $options['iv']
			? $options['iv']
			: mcrypt_create_iv($options['iv_size'], $options['rand_src']);
		$options['iv_return'] = !($options['iv'] && !$options['iv_return']);
		if ($options['padding'] && $options['mode'] == MCRYPT_MODE_CBC) {
			$options['padding'] = strtoupper($options['padding']);
			foreach (self::$paddingMethods as $k => $a) {
				if (in_array($options['padding'], $a['aliases'])) {
					#$debug->log('padding method '.$k.' ('.$options['padding'].')', $a['desc']);
					$pad_length = $options['block_size'] - strlen($string) % $options['block_size'];
					if ($k == 1) {
						$padding = str_repeat(chr($pad_length), $pad_length);
					} elseif ($k == 2) {
						$padding = chr(0x80).str_repeat(chr(0), $pad_length-1);
					} elseif ($k == 3) {
						$padding = str_repeat(chr(0), $pad_length-1).chr($pad_length);
					} elseif ($k == 4) {
						$padding = str_repeat(chr(0), $pad_length);
					} elseif ($k == 5 && $pad_length != $options['block_size']) {
						$padding = str_repeat(' ', $pad_length);
					}
					$string .= $padding;
					break;
				}
			}
		}
		$string	= ( $options['iv_return'] ? $iv : '' )
			.mcrypt_encrypt($options['cipher'], $key, $string, $options['mode'], $iv);
		if ($options['return_base64']) {
			#$debug->log('base64 encoding crypt text');
			$string = base64_encode($string);
		}
		return $string;
	}
324835
public function stringToObject($data, array $options=[])
  {
    $data = trim($data);
    if ( substr($data, 0, 1) !== '{' && substr($data, -1, 1) !== '}' ){
      return Format::getInstance('Yaml')->stringToObject($data, $options);
    }
    
    $decoded = json_decode($data);
    
    if ( $decoded === null ){
      throw new \RuntimeException(sprintf('Error decoding JSON data: %s', json_last_error_msg()));
    }
    
    return (object)$decoded;
  }
1005256
public function serialize($content, array $options = [])
    {
        $node = $content->getResourceNode();

        if (!empty($node)) {
            $serialized = $this->resourceContentSerializer->serialize($node, $options);
        } else {
            $serialized = [
                'type' => 'text/html',
                'data' => $content->getData(),
            ];
        }

        return $serialized;
    }