First external release

This commit is contained in:
Adrien Loison committed 2015-01-15 18:14:07 -08:00
commit 5e199009e6
81 files changed
+5447

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
<?php
namespace Box\Spout\Reader;
use Box\Spout\Common\Exception\UnsupportedTypeException;
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Common\Type;
/**
* Class ReaderFactory
* This factory is used to create readers, based on the type of the file to be read.
* It supports CSV and XLSX formats.
*
* @package Box\Spout\Reader
*/
class ReaderFactory
{
/**
* This creates an instance of the appropriate reader, given the type of the file to be read
*
* @param string $readerType Type of the reader to instantiate
* @return \Box\Spout\Reader\CSV|\Box\Spout\Reader\XLSX
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
*/
public static function create($readerType)
{
$reader = null;
switch ($readerType) {
case Type::CSV:
$reader = new CSV();
break;
case Type::XLSX:
$reader = new XLSX();
break;
default:
throw new UnsupportedTypeException('No readers supporting the given type: ' . $readerType);
}
$reader->setGlobalFunctionsHelper(new GlobalFunctionsHelper());
return $reader;
}
}