Example #1
0
 /**
  * Build replacements to perform for each entry
  */
 private function buildReplacements()
 {
     if ($this->csvFormat->getEscape()) {
         $this->escapeChars = [$this->csvFormat->getEscape(), $this->csvFormat->getDelimiter(), "\n", "\r", "\t"];
         if ($this->csvFormat->hasQuote() && !$this->csvFormat->useDoubleQuotes()) {
             $this->escapeChars[] = $this->csvFormat->getQuote();
         }
         $this->escapeChars = array_unique($this->escapeChars);
         $this->replaceChars = array_map(function ($char) {
             return $this->csvFormat->getEscape() . $char;
         }, $this->escapeChars);
     }
     if ($this->csvFormat->hasQuote() && $this->csvFormat->useDoubleQuotes()) {
         $this->escapeChars[] = $this->csvFormat->getQuote();
         $this->replaceChars[] = str_repeat($this->csvFormat->getQuote(), 2);
     }
 }