mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-24 23:37:41 +01:00
Don't read out old swar versions
This commit is contained in:
parent
f491a86ab6
commit
f925e08c29
@ -15,6 +15,7 @@ namespace JeroenED\Libpairtwo\Readers;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||
use JeroenED\Libpairtwo\Exceptions\IncompatibleReaderException;
|
||||
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
||||
use JeroenED\Libpairtwo\Tournament;
|
||||
|
||||
@ -33,9 +34,14 @@ class Swar4 implements ReaderInterface
|
||||
/** @var string */
|
||||
private $release;
|
||||
|
||||
/** @var array */
|
||||
private const CompatibleVersions = ['v4.'];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return ReaderInterface
|
||||
* @throws IncompatibleReaderException
|
||||
*/
|
||||
public function read(string $filename): ReaderInterface
|
||||
{
|
||||
@ -43,6 +49,10 @@ class Swar4 implements ReaderInterface
|
||||
|
||||
$this->setRelease($this->readData('String', $swshandle));
|
||||
|
||||
if (array_search(substr($this->getRelease(), 0, 3), self::CompatibleVersions) === false) {
|
||||
throw new IncompatibleReaderException("This file was not created with Swar 4");
|
||||
}
|
||||
|
||||
$this->setTournament(new Tournament());
|
||||
|
||||
$this->setBinaryData('Guid', $this->readData('String', $swshandle));
|
||||
|
Loading…
Reference in New Issue
Block a user