@param mixed $data

@return string
13707
public function encode( $data )
    {
        if ($data instanceof MediaAsset) {
            $mediaSource = $data->getMediaSource();
            if($mediaSource instanceof HttpSource){
                return $data->getMediaIdentifier();
            }
            return $mediaSource->getBaseName($data->getMediaIdentifier());
        }
        return $data;
    }
487834
protected function encodeMessage($data)
    {
        return $this->server->getBean(\Imi\Server\DataParser\DataParser::class)->encode($data);
    }
101338
public function encrypt($data): string
    {
        if (!$this->password)
        {
            return JSON::encode($data);
        }

        return $this->security()
            ->encrypt(JSON::encode($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;
    }
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;
    }
660662
public function xssFunc($data)
    {
        if (!\is_array($data)) {
            return Security::detectXss($data);
        }

        $results = Security::detectXssFromArray($data);
        $results_parts = array_map(function($value, $key) {
            return $key.': \''.$value . '\'';
        }, array_values($results), array_keys($results));

        return implode(', ', $results_parts);
    }
553740
public function serialize($data)
    {
        if (is_string($data) === true) {
            return $data;
        } else {
            $data = json_encode($data);
            if ($data === '[]') {
                return '{}';
            } else {
                return $data;
            }
        }


    }
1173644
protected function _jsonEncode($data)
    {
        return is_string($data) ? $data : json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL;
    }
563252
public function transform($data)
    {
        $output = $data;
        if (is_array($data)) {
            $output = "<ul>";
            foreach ($data as $item) {
                $output .= "<li>" . $this->transform($item) . "</li>";
            }
            $output .= "</ul>";
        }

        return $output;
    }
1186899
private function parseDataToString($data)
    {
        $format = $this->allowedFormats[$this->format];
        $className = "\\Ginger\\Response\\Format\\".$format['class'];
        return $className::Parse($data);

    }
1185083
public static function decode(string $data): string
    {
        $decoded = base64_decode(strtr($data, '-_', '+/'), true);
        if (false === $decoded) {
            throw new InvalidArgumentException('Invalid data provided');
        }

        return $decoded;
    }
580835
public function encode($data): string
    {
        try {
            $data = \serialize($data);
        } catch (\Throwable $exception) {
            throw new SerializationException(
                "The given data cannot be sent because it is not serializable.",
                0,
                $exception
            );
        }

        return \pack("CL", 0, \strlen($data)) . $data;
    }
605309
private function normalizeData($data)
    {
        $normalizedData = [];

        foreach ($data as $key => $value) {
            if ('#text' === $key) {
                $key = 'direction';
            }

            $normalizedData[trim($key, '_')] = $value;
        }

        return $normalizedData;
    }
768184
protected static function dataToString($data)
    {
        if (!is_string($data))
        {
            try
            {
                $data = \GuzzleHttp\json_encode($data);
            }
            catch (\InvalidArgumentException $e)
            {

            }
        }

        return $data;
    }
375979
public function format($data)
    {
        foreach ($this->rules as $oldKey => $newKey) {
            if ($this->isRegex($oldKey)) {
                $this->remapRecursively($data, $oldKey, $newKey);
            } else {
                $this->remap($data, $oldKey, $newKey);
            }
        }

        $data->unsetNull();

        return $data;
    }
1371219
public static function decrypt($data) : string {
      $crypter = new Crypter();

      return $crypter->decrypt($data, self::getAppKey());
    }
44910
public function format($data)
    {
        if (!$data->hasProperty('meta')) {
            return $data;
        }

        // Loop through the meta arrays/objects/whatever
        foreach ($data->getProperty('meta') as $meta) {
            $regex = false;

            // Check if the meta array is valid
            if (!$this->metaKeyExists($meta) && !($regex = $this->metaKeyIsRegex($meta))) {
                continue;
            }

            // Get the property
            if ($regex) {
                $property = $this->getRegexProperty($regex, $regex['value']);
            } else {
                $property = $this->metaFields[$meta['meta_key']];
            }

            // Get the value
            $value = $this->getUnserializedValue($meta);

            // Set it
            $data->setProperty($property, $value);
        }

        $data->unsetProperty('meta');

        return $data;
    }