mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-26 00:07:42 +01:00
ENHANCEMENT: Compatibility with Pairtwo-5
Filestructure of pairtwo-5 files are identical to pairtwo-6
This commit is contained in:
parent
4403401703
commit
7442df191e
@ -5,11 +5,13 @@ namespace JeroenED\Libpairtwo;
|
|||||||
|
|
||||||
use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
|
use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
|
||||||
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
||||||
|
use JeroenED\Libpairtwo\Readers\Pairtwo6;
|
||||||
|
|
||||||
abstract class IOFactory
|
abstract class IOFactory
|
||||||
{
|
{
|
||||||
private static $readers = [
|
private static $readers = [
|
||||||
'Pairtwo-6' => Readers\Pairtwo6::class
|
'Pairtwo-6' => Readers\Pairtwo6::class,
|
||||||
|
'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
|||||||
private const PT_MONTHFACTOR = 16;
|
private const PT_MONTHFACTOR = 16;
|
||||||
private const PT_YEARFACTOR = 512;
|
private const PT_YEARFACTOR = 512;
|
||||||
private const PT_PASTOFFSET = 117;
|
private const PT_PASTOFFSET = 117;
|
||||||
|
private const CompatibleVersions = ['6.', '5.'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads out $swsfile and returns a Pairtwo6 class object
|
* Reads out $swsfile and returns a Pairtwo6 class object
|
||||||
@ -71,8 +72,8 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
|||||||
$this->setRelease($this->readData('String', substr($swscontents, $offset, $length)));
|
$this->setRelease($this->readData('String', substr($swscontents, $offset, $length)));
|
||||||
$offset += $length;
|
$offset += $length;
|
||||||
|
|
||||||
if (substr($this->getRelease(), 0, 2) !== "6.") {
|
if (array_search(substr($this->getRelease(), 0, 2), self::CompatibleVersions) === false) {
|
||||||
throw new IncompatibleReaderException("This file was not created with Pairtwo 6 or higher");
|
throw new IncompatibleReaderException("This file was not created with Pairtwo 5 or higher");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setTournament(new Tournament());
|
$this->setTournament(new Tournament());
|
||||||
|
Loading…
Reference in New Issue
Block a user