Overview

Namespaces

  • Net
    • Bazzline
      • Component
        • Csv
          • Filter
          • Reader
          • Writer

Classes

  • Net\Bazzline\Component\Csv\AbstractBase
  • Net\Bazzline\Component\Csv\AbstractFactory
  • Net\Bazzline\Component\Csv\Filter\AbstractFilter
  • Net\Bazzline\Component\Csv\Filter\PermeableFilter
  • Net\Bazzline\Component\Csv\Reader\EasyCsvReaderAdapter
  • Net\Bazzline\Component\Csv\Reader\FilteredReader
  • Net\Bazzline\Component\Csv\Reader\FilteredReaderFactory
  • Net\Bazzline\Component\Csv\Reader\Reader
  • Net\Bazzline\Component\Csv\Reader\ReaderFactory
  • Net\Bazzline\Component\Csv\Writer\EasyCsvWriterAdapter
  • Net\Bazzline\Component\Csv\Writer\FilteredWriter
  • Net\Bazzline\Component\Csv\Writer\FilteredWriterFactory
  • Net\Bazzline\Component\Csv\Writer\FilteredWriterForPhp3Dot3
  • Net\Bazzline\Component\Csv\Writer\Writer
  • Net\Bazzline\Component\Csv\Writer\WriterFactory
  • Net\Bazzline\Component\Csv\Writer\WriterForPhp5Dot3

Interfaces

  • Net\Bazzline\Component\Csv\BaseInterface
  • Net\Bazzline\Component\Csv\FactoryInterface
  • Net\Bazzline\Component\Csv\Reader\ReaderInterface
  • Net\Bazzline\Component\Csv\Writer\WriterInterface

Exceptions

  • Net\Bazzline\Component\Csv\InvalidArgumentException
  • Net\Bazzline\Component\Csv\RuntimeException
  • Overview
  • Namespace
  • Class
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 
<?php
/**
 * @author stev leibelt <artodeto@bazzline.net>
 * @since 2015-05-16 
 */

namespace Net\Bazzline\Component\Csv\Writer;

class EasyCsvWriterAdapter
{
    /** @var Writer|WriterForPhp5Dot3|WriterInterface  */
    private $writer;

    /**
     * @param string $path
     * @param string $mode - is not used
     * @param null|WriterInterface $writer - optional
     */
    public function __construct($path, $mode = 'r+', WriterInterface $writer = null)
    {
        if (is_null($writer)) {
            $factory = new WriterFactory();
            $this->writer = $factory->create();
        } else {
            $this->writer = $writer;
        }

        $this->writer->setDelimiter(',');
        $this->writer->setEnclosure('"');
        $this->writer->setPath($path);
    }

    /**
     * @param string $delimiter
     */
    public function setDelimiter($delimiter)
    {
        $this->writer->setDelimiter($delimiter);
    }

    /**
     * @param string $enclosure
     */
    public function setEnclosure($enclosure)
    {
        $this->writer->setEnclosure($enclosure);
    }

    /**
     * @param mixed $row
     * @return false|int
     */
    public function writeRow($row)
    {
        return $this->writer->writeOne($row);
    }

    /**
     * @param array $array
     */
    public function writeFromArray(array $array)
    {
        $this->writer->writeMany($array);
    }
}
PHP Csv Component by bazzline.net API documentation generated by ApiGen