public function export( $destination, $overwriteIfExists = false )
    {

        if( !is_string( $destination ) ){
            throw new \RuntimeException(sprintf(
                'Expected $destination to be a string, got type: %s',
                gettype($destination)
            ));
        }

        if( file_exists( $destination ) and !$overwriteIfExists ) {
            throw new \RuntimeException( sprintf( "File '%s' already exists.", $destination ) );
        }

        if( !is_writable( dirname( $destination ) ) ){
            throw new \RuntimeException( sprintf( "File '%s' is not writable.", $destination ) );
        }

        if( isset( $this->filePath ) ) {
            return copy( $this->filePath, $destination );
        }

        $pg = $this->oid->pg;;

        $pg->query( new Query( 'BEGIN' ) );

        $result = pg_lo_export( $pg->resource->get(), $this->oid->oid, $destination );

        $pg->query( new Query( 'COMMIT' ) );

        return $result;

    }