private function transformToText($data, $hypertextRoutes = [], $depth = 0)
    {
        // Return the data as string if it's not an array
        if (!is_array($data)) {
            return "{$data}\n{$this->getHypertextString($hypertextRoutes)}";
        }

        // Loop through the data and add to the string
        $str = '';
        foreach ($data as $k => $v) {
            // Add tabs
            for ($i = 0; $i < $depth; $i++) {
                $str .= "\t";
            }

            if (is_array($v)) {
                // Recursively transform underlying data
                $str .= "{$k}: {$this->transformToText($v, [], $depth+1)}\n";
            } else {
                $str .= "{$k}: {$v}\n";
            }
        }

        // Add the hypertext routes
        $str .= $this->getHypertextString($hypertextRoutes);
        return $str;
    }
private function transformToText($data, $hypertextRoutes = [], $depth = 0)
    {
        // Return the data as string if it's not an array
        if (!is_array($data)) {
            return "{$data}\n{$this->getHypertextString($hypertextRoutes)}";
        }

        // Loop through the data and add to the string
        $str = '';
        foreach ($data as $k => $v) {
            // Add tabs
            for ($i = 0; $i < $depth; $i++) {
                $str .= "\t";
            }

            if (is_array($v)) {
                // Recursively transform underlying data
                $str .= "{$k}: {$this->transformToText($v, [], $depth+1)}\n";
            } else {
                $str .= "{$k}: {$v}\n";
            }
        }

        // Add the hypertext routes
        $str .= $this->getHypertextString($hypertextRoutes);
        return $str;
    }
private function transformToText ( $ data , $ hypertextRoutes = [ ] , $ depth = 0 ) { // Return the data as string if it's not an array if ( ! is_array ( $ data ) ) { return "{$data}\n{$this->getHypertextString($hypertextRoutes)}" ; } // Loop through the data and add to the string $ str = '' ; foreach ( $ data as $ k => $ v ) { // Add tabs for ( $ i = 0 ; $ i < $ depth ; $ i ++ ) { $ str .= "\t" ; } if ( is_array ( $ v ) ) { // Recursively transform underlying data $ str .= "{$k}: {$this->transformToText($v, [], $depth+1)}\n" ; } else { $ str .= "{$k}: {$v}\n" ; } } // Add the hypertext routes $ str .= $ this -> getHypertextString ( $ hypertextRoutes ) ; return $ str ; }
Recursively converts the response into a text string.

@param mixed $data The data to transform.
@param optional array $hypertextRoutes An array with hypertext routes.

@return string The response as a text string.
Recursively converts the response into a text string .