fabrn / ydk-file-reader
Simple PHP library for YDK file reading
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/fabrn/ydk-file-reader
Requires
- php: ^8.1
README
Simple PHP library that make .ydk file reading easier.
Install using Composer
composer require fabrn/ydkfilereader
Usage
In order to parse a specific YDK file, the Ydk::readFile will do the job :
$ydk = Ydk::readFile('my_file.ydk');
Once you've done that, you get an Ydk instance that contains everything you need
to read the parsed file using public properties :
- author : if mentioned, the author can be retrieved
- mainDeck : list of card IDs of the main deck
- extraDeck : list of card IDs of the extra deck
- sideDeck : list of card IDs of the side deck
Using a custom parser
If, for some reason, you need to use a custom YDK parser, you can create one :
class MyYdkParser implements YdkParserInterface { public function parse(string $ydk): array { // TODO : parse YDK content } }
Then use the parser by giving it as a second argument to the readFile method :
$ydk = Ydk::readFile('my_file.ydk', new MyYdkParser());
Directly parse YDK content
The Ydk class' constructor takes some raw YDK content to parse. The readFile is
useful to get a file's content and construct the Ydk instance with it. But, if you
need to, you can give it yourself :
$ydk = new Ydk($ydkContent);
Note that you can also use a custom parser using the constructor :
$ydk = new Ydk($ydkContent, new MyYdkParser());
License and legal notice
This package is available under MIT license.