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);
    }