Stash\Driver\FileSystem\NativeEncoder::encode PHP Method

encode() protected method

Finds the method of encoding that has the cheapest decode needs and encodes the data with that method.
protected encode ( string $data ) : string
$data string
return string
    protected function encode($data)
    {
        switch (Utilities::encoding($data)) {
            case 'bool':
                $dataString = (bool) $data ? 'true' : 'false';
                break;
            case 'string':
                $dataString = sprintf('"%s"', addcslashes($data, "\t\"\$\\"));
                break;
            case 'numeric':
                $dataString = (string) $data;
                break;
            default:
            case 'serialize':
                $dataString = 'unserialize(base64_decode(\'' . base64_encode(serialize($data)) . '\'))';
                break;
        }
        return $dataString;
    }