Esempio n. 1
0
 /**
  * Creates a CSV Writer
  *
  * @param string $filename
  * @param string $delimiter
  * @param string $enclosure
  * @param string $escape
  * @param string $openMode
  * @return \PhillipsData\Csv\Reader
  */
 public static function writer($filename, $delimiter = ',', $enclosure = '"', $escape = '\\', $openMode = 'w')
 {
     $file = static::fileObject($filename, $openMode);
     $file->setCsvControl($delimiter, $enclosure, $escape);
     $writer = Writer::output($file);
     return $writer;
 }
Esempio n. 2
0
 /**
  * @dataProvider formatterProvider
  * @covers ::isWritable
  * @covers ::write
  * @covers ::writeRow
  * @covers ::output
  * @covers \PhillipsData\Csv\AbstractCsv
  */
 public function testFormatters($data, $expected)
 {
     $file = $this->getSplFixtureFile();
     $writer = Writer::output($file);
     $writer->format(function ($row) {
         foreach ($row as $key => &$value) {
             $value = strtoupper($value);
         }
         return $row;
     });
     $writer->write($data);
     $actual = [];
     foreach ($file as $row) {
         $actual[] = $row;
     }
     $this->assertEquals($expected, $actual);
 }