mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2025-01-24 11:26:45 +01:00
Jeroen De Meerleer
922c1cfdbc
* NEW FEATURE: Added clean-dist and clean-dev targets * ENHANCEMENT: Resized logo in Doxygen for better fit * ENHANCEMENT: Doxygen takes branch name or version tag as `PROJECT_NUMBER` * CHANGE: Version tag directly put in distribution filename * CHANGE: `Tournament::GameExists()` renamed to `Tournament::gameExists()` * CHANGE: Updated composer metadata * CHANGE: Some setters changed to fluent setters. (More info: 7aca35057c10d2b982f93a698499c0c01df2fdc5)
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* 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>
|
|
*/
|
|
|
|
namespace JeroenED\Libpairtwo;
|
|
|
|
use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
|
|
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
|
use JeroenED\Libpairtwo\Readers\Pairtwo6;
|
|
|
|
/**
|
|
* 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>
|
|
*/
|
|
abstract class IOFactory
|
|
{
|
|
/**
|
|
* Compatible readers
|
|
*
|
|
* @var array
|
|
*/
|
|
private static $readers = [
|
|
'Pairtwo-6' => Readers\Pairtwo6::class,
|
|
'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical
|
|
];
|
|
|
|
|
|
/**
|
|
* Creates a reader for $type
|
|
*
|
|
* Compatible types are Pairtwo-5 and Pairtwo-6
|
|
*
|
|
* @param string $type
|
|
* @return ReaderInterface
|
|
* @throws LibpairtwoException
|
|
*/
|
|
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;
|
|
}
|
|
}
|