src/main/php/response/mimetypes/Csv.php
private function serializeIterable($resource, OutputStream $out)
    {
        $memory = fopen('php://memory', 'wb');
        if (is_array($resource) && is_scalar(current($resource))) {
            if (!is_numeric(key($resource))) {
                $out->write($this->toCsvLine(array_keys($resource), $memory));
            }

            $out->write($this->toCsvLine($resource, $memory));
        } else {
            $head = true;
            foreach (Sequence::of($resource)->map('stubbles\sequence\castToArray') as $elements) {
                if ($head && !is_numeric(key($elements))) {
                    $out->write($this->toCsvLine(array_keys($elements), $memory));
                }

                $head = false;
                $out->write($this->toCsvLine($elements, $memory));
            }
        }

        fclose($memory);
    }
private function serializeIterable($resource, OutputStream $out)
    {
        $memory = fopen('php://memory', 'wb');
        if (is_array($resource) && is_scalar(current($resource))) {
            if (!is_numeric(key($resource))) {
                $out->write($this->toCsvLine(array_keys($resource), $memory));
            }

            $out->write($this->toCsvLine($resource, $memory));
        } else {
            $head = true;
            foreach (Sequence::of($resource)->map('stubbles\sequence\castToArray') as $elements) {
                if ($head && !is_numeric(key($elements))) {
                    $out->write($this->toCsvLine(array_keys($elements), $memory));
                }

                $head = false;
                $out->write($this->toCsvLine($elements, $memory));
            }
        }

        fclose($memory);
    }
private function serializeIterable ( $ resource , OutputStream $ out ) { $ memory = fopen ( 'php://memory' , 'wb' ) ; if ( is_array ( $ resource ) && is_scalar ( current ( $ resource ) ) ) { if ( ! is_numeric ( key ( $ resource ) ) ) { $ out -> write ( $ this -> toCsvLine ( array_keys ( $ resource ) , $ memory ) ) ; } $ out -> write ( $ this -> toCsvLine ( $ resource , $ memory ) ) ; } else { $ head = true ; foreach ( Sequence :: of ( $ resource ) -> map ( 'stubbles\sequence\castToArray' ) as $ elements ) { if ( $ head && ! is_numeric ( key ( $ elements ) ) ) { $ out -> write ( $ this -> toCsvLine ( array_keys ( $ elements ) , $ memory ) ) ; } $ head = false ; $ out -> write ( $ this -> toCsvLine ( $ elements , $ memory ) ) ; } } fclose ( $ memory ) ; }
serializes iterable to csv

@param  iterable  $resource
@param  \stubbles\streams\OutputStream  $out
serializes iterable to csv