Tranforms a string containing public urls to string with internal urls.

@param string $data
@return null|string
356049
public function reverseTransform($data)
    {
        if (self::MODE_TO_INTERNAL === (self::MODE_TO_INTERNAL & $this->mode)) {
            return $this->map($data, UrlMapperInterface::MODE_PUBLIC_TO_INTERNAL);
        } else {
            return $data;
        }
    }
406893
protected function parseStringAsTemplate($data)
    {
        $t = $html = $data;

        while (preg_match("/[{]([^{}]+)[}]/", $t, $regs)) {
            $t = str_replace($regs[0], "", $t);

            $input = $this->generateValue($regs[1]);

            if ($input !== null && $input !== false && $input !== $regs[1]) {
                $html = str_replace($regs[0], (string)$input, $html);
            }
        }

        return $html;
    }
1320070
public static function toString($data)
    {
        if (is_array($data)) {
            $newData = [];
            foreach ($data as $key => $val) {
                $key = (string)$key;
                $newData[$key] = static::toString($val);
            }
        } else {
            $newData = (string)$data;
        }

        return $newData;
    }
144025
public function unredislize($data)
    {
        $data = urldecode($data);

        if (self::isSerialized($data)) {
            $unserializedData = @unserialize($data);
            if ($unserializedData !== false) {
                return $unserializedData;
            }
        }

        return $data;
    }
907691
public static function decodeUrlSafe($data) {
		$data = \strtr(
			$data,
			self::LAST_THREE_URL_SAFE,
			self::LAST_THREE_STANDARD
		);

		return self::decode($data);
	}
578741
protected function _unserialize($data)
	{
		$data = @unserialize(stripslashes($data));

		if (is_array($data))
		{
			foreach ($data as $key => $val)
			{
				if (is_string($val))
				{
					$data[$key] = str_replace('{{slash}}', '\\', $val);
				}
			}

			return $data;
		}

		return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
	}
890723
private function doEncode($data = null)
    {
        $data = is_null($data) ? $this->data : $data;

        if (is_array($data) && (isset ($data[0]) || empty ($data))) {
            return $this->encodeList($data);
        } elseif (is_array($data)) {
            return $this->encodeDict($data);
        } elseif (is_integer($data) || is_float($data)) {
            $data = sprintf("%.0f", round($data, 0));
            return $this->encodeInteger($data);
        } else {
            return $this->encodeString($data);
        }
    }
1043970
public function urlize(string $string) : string
    {
        // Remove all non url friendly characters with the unaccent function
        $unaccented = $this->unaccent($string);

        if (function_exists('mb_strtolower')) {
            $lowered = mb_strtolower($unaccented);
        } else {
            $lowered = strtolower($unaccented);
        }

        $replacements = [
            '/\W/' => ' ',
            '/([A-Z]+)([A-Z][a-z])/' => '\1_\2',
            '/([a-z\d])([A-Z])/' => '\1_\2',
            '/[^A-Z^a-z^0-9^\/]+/' => '-',
        ];

        $urlized = $lowered;

        foreach ($replacements as $pattern => $replacement) {
            $replaced = preg_replace($pattern, $replacement, $urlized);

            if ($replaced === null) {
                throw new RuntimeException(sprintf(
                    'preg_replace returned null for value "%s"',
                    $urlized
                ));
            }

            $urlized = $replaced;
        }

        return trim($urlized, '-');
    }
373703
public function getUrl(array $data = []) {
        // Guess the what URL should be looked like
        $translation_guess = preg_replace(['/\[([^\[]+)\]/is', '/{(\w*?)}/is', '/{(\w*?):(:?.*?)}/is'], '{$1}', $this->_path);
        
        $keys = [];
        preg_match_all('/{(\w*?)}/is', $translation_guess, $keys);

        foreach ($keys[1] as $key) {
            $translation_guess = str_replace('{'.$key.'}', isset($data[$key]) ? $data[$key] : 'null', $translation_guess);
        }

        // Get raw pattern from route
        $translation = preg_replace(['/\//is', '/\[([^\[]+)\]/is', '/{(\w*?)}/is'],['\/', '(?:$1)?', '{$1:([^\/]+)}'], $this->_path);
        $keyex = [];
        preg_match_all('/{(\w*?):(.*?)}/', $translation, $keyex);
        $groups = array_map(function($val) {
            return '(' . trim(trim($val, ')'), '(') . ')';
        }, $keyex[2]);
        $translation = str_replace($keyex[0], $groups, $translation);

        // Check if guess is valid
        $test = preg_match("#^$translation$#is", $translation_guess, $vals);

        return $test ? $translation_guess : '';
    }
54833
public static function fromString(string $data): self
    {
        if (false === $image = imagecreatefromstring($data)) {
            throw new InvalidArgumentException('Could not read image');
        }

        return new static($image);
    }
329995
protected function encode($data)
    {
        if(null === $this->formatHandlerClass)
        {
            return $data;
        }
        else if(RequestContext::exsits() && null !== RequestContext::getServer())
        {
            return RequestContext::getServerBean($this->formatHandlerClass)->encode($data);
        }
        else
        {
            return App::getBean($this->formatHandlerClass)->encode($data);
        }
    }
1021892
public static function transPostFile($data)
    {
        if (PHP_VERSION_ID < 50500 || ! is_array($data)) {
            return $data;
        }
        foreach ($data as &$v) {
            if (is_string($v) && substr($v, 0, 1) == '@') {
                $file_path = substr($v, 1);
                is_file($file_path) && ($v = new CURLFile($file_path));
            }
        }
        return $data;
    }
932134
public function format(array $data)
    {
        $value = parent::format($data);
        foreach ($this->list as $uri => $values) {
            if (in_array($value, $values)) {
                return $uri;
            }
        }
        return '';
    }
160374
public function encode($data)
    {
        if ($data !== null) {
            $data = gzencode((string) $data, $this->options['level'], $this->options['mode']);
            if ($data === false) {
                $data = null;
                $this->error = error_get_last()['message'] ?? 'Unknown';
            }
        }

        return $data;
    }
582948
protected function _toString($data) {
		foreach ($data as $key => $val) {
			switch (true) {
				case is_object($val) && !$val instanceof \Closure:
					try {
						$data[$key] = (string) $val;
					} catch (Exception $e) {
						$data[$key] = '';
					}
				break;
				case is_array($val):
					$data = array_merge($data, Set::flatten($val));
				break;
			}
		}
		return $data;
	}
80647
final private static function encodeString(string $data): string
    {
        $buf = '';
        self::encodeUnsigned($buf, strlen($data));
        return $buf . $data;
    }
220788
public static function encode(/*mixed*/ $data) {
    $json = json_encode($data, JSON_UNESCAPED_SLASHES);

    // Turn some special characters into their JSON representation.
    $json = str_replace(["\t", "\r", "\n"], ['\\t', '\\r', '\\n'], $json);

    return $json;
  }