diff --git a/Converting-your-code-to-the-generalized-format.md b/Converting-your-code-to-the-generalized-format.md new file mode 100644 index 0000000..1abb48e --- /dev/null +++ b/Converting-your-code-to-the-generalized-format.md @@ -0,0 +1,20 @@ +Currently the project is in the phase of transforming from pairtwo-only to a generalized view for multiple programs. +This makes it relatively easy to add other filetypes. However, this process requires rewriting and renaming some functions. This document is dedicated to these adjustments. + +## `Sws::readSws` renamed to `ReaderInterface::read` + +When you want to read a file, all you need to do is to create an instance of the ReaderInterface and call its read function. This procedure will be the same for any filetype in the library. + +I have created a easy class to get to the right class for your file. This IOFactory class currently only has 1 type which is for Pairtwo (starting from version 6). But there will be added other filetypes as well. + +### Old code +```php +require_once 'vendor/autoload.php'; +$sws = Sws::readSws(''); +``` + +### New code +```php +require_once 'vendor/autoload.php'; +$reader = IOFactory::createReader('Pairtwo-6'); +$sws = $reader->read('');