| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | public function save( $file_path, $allow_empty = true ) { |
||
| 40 | |||
| 41 | // Not saving empty files if empty files are not allowed to be saved |
||
| 42 | if ( ! $allow_empty && empty( $this->items ) ) { |
||
| 43 | return ''; |
||
| 44 | } |
||
| 45 | |||
| 46 | $handle = fopen( $file_path, 'w+' ); |
||
| 47 | foreach ( $this->items as $item ) { |
||
| 48 | fputcsv( $handle, $item->to_csv_array() ); |
||
| 49 | } |
||
| 50 | rewind( $handle ); |
||
| 51 | $contents = stream_get_contents( $handle ); |
||
| 52 | fclose( $handle ); |
||
| 53 | return $contents; |
||
| 54 | } |
||
| 55 | } |
||
| 56 |