2019-05-27 13:01:37 +02:00
|
|
|
<?php
|
2019-06-19 19:49:39 +02:00
|
|
|
/**
|
|
|
|
* Class IOFactory
|
|
|
|
*
|
|
|
|
* Class for creating readers for pairing files
|
|
|
|
*
|
|
|
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
|
|
|
* @category Main
|
|
|
|
* @package Libpairtwo
|
|
|
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
|
|
|
*/
|
2019-05-27 13:01:37 +02:00
|
|
|
|
|
|
|
namespace JeroenED\Libpairtwo;
|
|
|
|
|
|
|
|
use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
|
|
|
|
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
2019-05-28 10:16:34 +02:00
|
|
|
use JeroenED\Libpairtwo\Readers\Pairtwo6;
|
2019-05-27 13:01:37 +02:00
|
|
|
|
2019-06-19 19:49:39 +02:00
|
|
|
/**
|
|
|
|
* Class IOFactory
|
|
|
|
*
|
|
|
|
* Class for creating readers for pairing files
|
|
|
|
*
|
|
|
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
|
|
|
* @category Main
|
|
|
|
* @package Libpairtwo
|
|
|
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
|
|
|
*/
|
2019-05-27 13:01:37 +02:00
|
|
|
abstract class IOFactory
|
|
|
|
{
|
2019-06-19 19:49:39 +02:00
|
|
|
/**
|
|
|
|
* Compatible readers
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2019-05-27 13:01:37 +02:00
|
|
|
private static $readers = [
|
2019-05-28 10:16:34 +02:00
|
|
|
'Pairtwo-6' => Readers\Pairtwo6::class,
|
|
|
|
'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical
|
2019-05-27 13:01:37 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a reader for $type
|
|
|
|
*
|
|
|
|
* @param string $type
|
|
|
|
* @return ReaderInterface
|
|
|
|
*/
|
|
|
|
public static function createReader(string $type): ReaderInterface
|
|
|
|
{
|
|
|
|
if (!isset(self::$readers[$type])) {
|
|
|
|
throw new LibpairtwoException("Cannot read type $type");
|
|
|
|
}
|
|
|
|
|
|
|
|
// create reader class
|
|
|
|
$readerClass = self::$readers[$type];
|
|
|
|
$reader = new $readerClass;
|
|
|
|
|
|
|
|
return $reader;
|
|
|
|
}
|
|
|
|
}
|