src/Utility/Export.php
protected function create(array $data, string $mode = 'a'): void
    {
        // create file path
        $file = new File($this->path, true);

        // skip if file is not writable
        if (! $file->writable()) {
            $this->log(sprintf('Export file is not writable: %s', $file->pwd()), LogLevel::ERROR);

            return;
        }

        /**
         * @var resource
         */
        $handler = fopen($file->pwd(), $mode);
        if (! is_resource($handler)) {
            $this->log(sprintf('Export interrupted: failed to bind resource to a stream'), LogLevel::ERROR);
        }

        foreach ($data as $row) {
            if (false === fputcsv($handler, $row)) {
                $this->log(sprintf('Export interrupted: failed to write data into the file'), LogLevel::ERROR);

                return;
            }
        }

        fclose($handler);
    }
protected function create(array $data, string $mode = 'a'): void
    {
        // create file path
        $file = new File($this->path, true);

        // skip if file is not writable
        if (! $file->writable()) {
            $this->log(sprintf('Export file is not writable: %s', $file->pwd()), LogLevel::ERROR);

            return;
        }

        /**
         * @var resource
         */
        $handler = fopen($file->pwd(), $mode);
        if (! is_resource($handler)) {
            $this->log(sprintf('Export interrupted: failed to bind resource to a stream'), LogLevel::ERROR);
        }

        foreach ($data as $row) {
            if (false === fputcsv($handler, $row)) {
                $this->log(sprintf('Export interrupted: failed to write data into the file'), LogLevel::ERROR);

                return;
            }
        }

        fclose($handler);
    }
protected function create ( array $ data , string $ mode = 'a' ) : void { // create file path $ file = new File ( $ this -> path , true ) ; // skip if file is not writable if ( ! $ file -> writable ( ) ) { $ this -> log ( sprintf ( 'Export file is not writable: %s' , $ file -> pwd ( ) ) , LogLevel :: ERROR ) ; return ; } /**
         * @var resource
         */ $ handler = fopen ( $ file -> pwd ( ) , $ mode ) ; if ( ! is_resource ( $ handler ) ) { $ this -> log ( sprintf ( 'Export interrupted: failed to bind resource to a stream' ) , LogLevel :: ERROR ) ; } foreach ( $ data as $ row ) { if ( false === fputcsv ( $ handler , $ row ) ) { $ this -> log ( sprintf ( 'Export interrupted: failed to write data into the file' ) , LogLevel :: ERROR ) ; return ; } } fclose ( $ handler ) ; }
Create export file.

@param mixed[] $data CSV data
@param string $mode File mode
@return void
Create export file .