encode value
@param  mixed $data
@return mixed
496380
protected function encodeValue($data)
	{
	    // xml wrap entity_element label
	    if ($this->options['data_format'] == 'xml') {
	        $data = $this->formatter->wrap($data, $this->options['entity_element']);
	    }
	    return $this->formatter->encode($data);
	}
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;
    }
1288235
public static function encode($data)
    {
        if (is_object($data)) {
            if (method_exists($data, "toArray")) {
                $data = $data->toArray();
            } else {
                $data = (array) $data;
            }
        }

        $encoder = new self($data);
        $encoded = $encoder->doEncode();

        return $encoded;
    }
80647
final private static function encodeString(string $data): string
    {
        $buf = '';
        self::encodeUnsigned($buf, strlen($data));
        return $buf . $data;
    }
894568
public function encode($data): string
    {
        $encoded = @json_encode($data, $this->getEncodeOptions());

        if ($encoded === false && json_last_error() !== JSON_ERROR_NONE) {
            throw new \RuntimeException('Encoding JSON failed: ' . json_last_error_msg());
        }

        return $encoded;
    }
1229801
public static function encode($data, array $context = [])
    {
        $context = array_merge(static::$defaultEncodeContext, $context);

        return static::encodeData($data, $context);
    }
695372
public function encode($data)
    {
        list($data, $consumed, $error) = $this->encodeTransform()
            ->transform($data, $context, true);

        if (null !== $error) {
            throw $error;
        }

        return $data;
    }
715757
public static function encode($data, $pad = null) {
		$str = str_replace(array('+', '/'), array('-', '_'), base64_encode($data));
		if (!$pad) {
			$str = rtrim($str, '=');
		}
		return $str;
	}
333983
private function encode($data)
    {
        $rdm = $this->random();
        $data = base64_encode($data);
        $startIndex = rand(1, strlen($rdm));
        $params = base64_encode($startIndex).self::ENC_SEPARATOR;
        $params .= base64_encode(strlen($data)).self::ENC_SEPARATOR;

        return $params.substr_replace($rdm, $data, $startIndex, 0);
    }
292090
public static function utf8Encode($data) {
		if (is_string($data)) {
			return utf8_encode($data);

		} else if (is_array($data)) {
			foreach ($data as $key => $value) {
				$data[utf8_encode($key)] = self::utf8Encode($value);
			}

		} else if (is_object($data)) {
			foreach ($data as $key => $value) {
				$data->{$key} = self::utf8Encode($value);
			}
		}

		return $data;
	}
1298062
public function decode(string $data): string
    {
        $this->validateInput($data);

        $data = str_split($data);
        $data = array_map(function ($character) {
            return strpos($this->options["characters"], $character);
        }, $data);

        $leadingZeroes = 0;
        while (!empty($data) && 0 === $data[0]) {
            $leadingZeroes++;
            array_shift($data);
        }

        $converted = $this->baseConvert($data, 62, 256);

        if (0 < $leadingZeroes) {
            $converted = array_merge(
                array_fill(0, $leadingZeroes, 0),
                $converted
            );
        }

        return implode("", array_map("chr", $converted));
    }
545646
private function encodeDict(array $data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        ksort($data); // bencode spec requires dicts to be sorted alphabetically

        $dict = "";
        foreach ($data as $key => $value) {
            $dict .= $this->encodeString($key) . $this->doEncode($value);
        }

        return "d{$dict}e";
    }
598413
public static function encode($data): string
    {
        $json = json_encode($data);

        if ($json === false) {
            $errNo = json_last_error();
            $msg = json_last_error_msg();
            throw new Exception("Unable to encode data to JSON, error ({$errNo}): {$msg}", $errNo);
        }

        return $json;
    }
1352219
public function encodeArray($data) {
        $d = array();
        foreach ($data as $key => $value) {
            if (is_string($key))
                $key = htmlspecialchars($key);
            if (is_string($value))
                $value = htmlspecialchars($value);
            elseif (is_array($value))
                $value = self::encodeArray($value);
            $d[$key] = $value;
        }
        return $d;
    }
611791
static function encode53($data)
	{
		return preg_replace_callback('/\\\\ud([89ab][0-9a-f]{2})\\\\ud([c-f][0-9a-f]{2})|\\\\u([0-9a-f]{4})/i', function($val)
		{
			return html_entity_decode(
				empty($val[3]) ?
					sprintf('&#x%x;', ((hexdec($val[1])&0x3FF)<<10)+(hexdec($val[2])&0x3FF)+0x10000)
				:
					'&#x'.$val[3].';', ENT_NOQUOTES, 'utf-8'
			);
		}, json_encode($data));
	}
84186
public function encode($data)
    {
        return openssl_encrypt($data, $this->method, $this->key, 0, $this->iv);
    }
1171957
private function encodeInteger($data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        return sprintf("i%.0fe", $data);
    }