private static function decideEncode($object, &$serialized)
    {
        switch ($type = gettype($object)) {
            case 'integer':
                $serialized .= "i{$object}e";
                break;

            case 'string':
                self::encodeString($object, $serialized);
                break;

            case 'array':
                $function = self::getArraySerializer($object);
                self::$function($object, $serialized);
                break;

            case 'boolean':
                $serialized .= $object === true ? 'i1e' : 'i0e';
                break;

            default:
                throw new EncodingException("Invalid type for encoding: $type", $object);
        }
    }