Skip to content

Commit 9e01479

Browse files
author
Stanislav Idolov
authored
Refactored code for avoiding copy/paste
1 parent 68e0878 commit 9e01479

File tree

1 file changed

+7
-13
lines changed
  • lib/internal/Magento/Framework/File

1 file changed

+7
-13
lines changed

lib/internal/Magento/Framework/File/Csv.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,23 @@ public function getDataPairs($file, $keyIndex = 0, $valueIndex = 1)
126126
/**
127127
* Saving data row array into file
128128
*
129-
* @param string $file
130-
* @param array $data
131-
* @return $this
129+
* @param string $file
130+
* @param array $data
131+
* @return $this
132132
* @throws \Magento\Framework\Exception\FileSystemException
133133
* @deprecated
134134
* @see appendData
135135
*/
136136
public function saveData($file, $data)
137137
{
138-
$fh = fopen($file, 'w');
139-
foreach ($data as $dataRow) {
140-
$this->file->filePutCsv($fh, $dataRow, $this->_delimiter, $this->_enclosure);
141-
}
142-
fclose($fh);
143-
return $this;
138+
return $this->appendData($file, $data, 'w');
144139
}
145140

146141
/**
147-
* Replace the saveData method by
148-
* allowing to select the input mode
142+
* Replace the saveData method by allowing to select the input mode
149143
*
150-
* @param $file
151-
* @param $data
144+
* @param string $file
145+
* @param array $data
152146
* @param string $mode
153147
*
154148
* @return $this

0 commit comments

Comments
 (0)