From 6ac07927af5e306286c01dc5d651fed3a18f0303 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Mon, 27 May 2019 13:01:37 +0200 Subject: [PATCH] Added IOFactory --- src/IOFactory.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/IOFactory.php diff --git a/src/IOFactory.php b/src/IOFactory.php new file mode 100644 index 0000000..d5f7526 --- /dev/null +++ b/src/IOFactory.php @@ -0,0 +1,34 @@ + Readers\Pairtwo6::class + ]; + + + /** + * 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; + } +}