mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-15 19:37:51 +01:00
Added transition page
parent
27941cdd1e
commit
6e3c972a2c
20
Converting-your-code-to-the-generalized-format.md
Normal file
20
Converting-your-code-to-the-generalized-format.md
Normal file
@ -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('<filename>');
|
||||||
|
```
|
||||||
|
|
||||||
|
### New code
|
||||||
|
```php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
$reader = IOFactory::createReader('Pairtwo-6');
|
||||||
|
$sws = $reader->read('<filename>');
|
Loading…
Reference in New Issue
Block a user