summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgnace Nyamagana Butera <nyamsprod@gmail.com>2015-01-23 12:39:51 +0100
committerIgnace Nyamagana Butera <nyamsprod@gmail.com>2015-01-23 12:39:51 +0100
commit58d4a584a5c2503f99723a1d685d1eadb72c9735 (patch)
treed011e3da06a7f820e64da29910d6271435e9190f /src
parentff0126e9b8f986fb2cc85638c90bd0d37d1d91aa (diff)
downloadcsv-58d4a584a5c2503f99723a1d685d1eadb72c9735.zip
csv-58d4a584a5c2503f99723a1d685d1eadb72c9735.tar.gz
csv-58d4a584a5c2503f99723a1d685d1eadb72c9735.tar.bz2
improve Factory trait
Diffstat (limited to 'src')
-rw-r--r--src/AbstractCsv.php44
-rw-r--r--src/Config/Factory.php44
2 files changed, 44 insertions, 44 deletions
diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php
index c29135d..f3a0e30 100644
--- a/src/AbstractCsv.php
+++ b/src/AbstractCsv.php
@@ -156,6 +156,50 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate
}
/**
+ * Create a {@link AbstractCsv} instance from another {@link AbstractCsv} object
+ *
+ * @param string $class_name the class to be instantiated
+ * @param string $open_mode the file open mode flag
+ *
+ * @return static
+ */
+ protected function newInstance($class_name, $open_mode)
+ {
+ $csv = new $class_name($this->path, $open_mode);
+ $csv->delimiter = $this->delimiter;
+ $csv->enclosure = $this->enclosure;
+ $csv->escape = $this->escape;
+ $csv->encodingFrom = $this->encodingFrom;
+ $csv->bom = $this->bom;
+
+ return $csv;
+ }
+
+ /**
+ * Create a {@link Writer} instance from a {@link AbstractCsv} object
+ *
+ * @param string $open_mode the file open mode flag
+ *
+ * @return \League\Csv\Writer
+ */
+ public function newWriter($open_mode = 'r+')
+ {
+ return $this->newInstance('\League\Csv\Writer', $open_mode);
+ }
+
+ /**
+ * Create a {@link Reader} instance from a {@link AbstractCsv} object
+ *
+ * @param string $open_mode the file open mode flag
+ *
+ * @return \League\Csv\Reader
+ */
+ public function newReader($open_mode = 'r+')
+ {
+ return $this->newInstance('\League\Csv\Reader', $open_mode);
+ }
+
+ /**
* Validate a variable to be stringable
*
* @param object|string $str
diff --git a/src/Config/Factory.php b/src/Config/Factory.php
index 53e039b..32d1176 100644
--- a/src/Config/Factory.php
+++ b/src/Config/Factory.php
@@ -112,48 +112,4 @@ trait Factory
return static::createFromFileObject($obj);
}
-
- /**
- * Create a {@link AbstractCsv} instance from another {@link AbstractCsv} object
- *
- * @param string $class_name the class to be instantiated
- * @param string $open_mode the file open mode flag
- *
- * @return static
- */
- protected function newInstance($class_name, $open_mode)
- {
- $csv = new $class_name($this->path, $open_mode);
- $csv->delimiter = $this->delimiter;
- $csv->enclosure = $this->enclosure;
- $csv->escape = $this->escape;
- $csv->encodingFrom = $this->encodingFrom;
- $csv->bom = $this->bom;
-
- return $csv;
- }
-
- /**
- * Create a {@link Writer} instance from a {@link AbstractCsv} object
- *
- * @param string $open_mode the file open mode flag
- *
- * @return \League\Csv\Writer
- */
- public function newWriter($open_mode = 'r+')
- {
- return $this->newInstance('\League\Csv\Writer', $open_mode);
- }
-
- /**
- * Create a {@link Reader} instance from a {@link AbstractCsv} object
- *
- * @param string $open_mode the file open mode flag
- *
- * @return \League\Csv\Reader
- */
- public function newReader($open_mode = 'r+')
- {
- return $this->newInstance('\League\Csv\Reader', $open_mode);
- }
}