$cells Cells. * @return string */ public static function line( array $cells ): string { $out = array(); foreach ( $cells as $cell ) { $text = self::cell( $cell ); $out[] = ( false !== strpbrk( $text, ",\"\n\r" ) ) ? '"' . str_replace( '"', '""', $text ) . '"' : $text; } return implode( ',', $out ) . "\n"; } }