public function save(array $headers, array $data)
    {
        $output = $contents = [];

        $enclosure = $this->getCsvEnclosure();
        $delimiter = $this->getCsvDelimiter();

        $contents[] = $enclosure
            . implode($enclosure . $delimiter . $enclosure, $headers)
            . $enclosure;

        if (!empty($data)) {
            foreach ($data as $item) {
                foreach ($item as $line) {
                    foreach ($headers as $index => $value) {
                        if (isset($line[$value]) && $line[$value] !== '') {
                            $output[$value] = $enclosure . (string)$line[$value] . $enclosure;
                            unset($line[$value]);
                        } else {
                            $output[$value] = '';
                        }
                    }
                    $contents[] = implode($delimiter, array_merge($output, $line));
                }
            }
        }

        $filePath = $this->getFilePath();

        if (file_put_contents($filePath, chr(239) . chr(187) . chr(191) . implode("\n", $contents))) {
            return $filePath;
        }

        return '';
    }