mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 14:07:42 +01:00
deleted getting started.md
moved to https://github.com/JeroenED/libpairtwo/wiki/1.-Getting-Started
This commit is contained in:
parent
21d105627e
commit
a10b0dd9de
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
@ -1,69 +0,0 @@
|
||||
# Getting started
|
||||
|
||||
## Installing Libpairtwo
|
||||
You can easily start using libpairtwo by installing it via composer
|
||||
|
||||
```bash
|
||||
$ composer install JeroenED/libpairtwo
|
||||
```
|
||||
|
||||
In you initialization code add the vendor/autoload.php
|
||||
```php
|
||||
require_once("vendor/autoload.php");
|
||||
```
|
||||
|
||||
## Reading out a sws-file
|
||||
Reading out a sws-file is very simple. Just call the Sws::ReadSws() method.
|
||||
|
||||
```php
|
||||
$sws = JeroenED\Libpairtwo\Sws::ReadSws("Clubcompetition.sws");
|
||||
```
|
||||
This will return a usable object for reaching out for results, rankings, etc.
|
||||
|
||||
## Getting methods of the class
|
||||
I didn't want to add the generated phpdoc in this library simply because it is generated.
|
||||
|
||||
The command to generate it yourself is just `$ phpdoc`. This will generate the docs in the doc/api folder.
|
||||
|
||||
## Examples
|
||||
|
||||
### Getting results of a tournament
|
||||
```php
|
||||
<?php
|
||||
|
||||
require_once("vendor/autoload.php");
|
||||
use JeroenED\Libpairtwo\Sws;
|
||||
$sws = Sws::ReadSws("Clubcompetition.sws");
|
||||
|
||||
$tournament = $sws->getTournament();
|
||||
$calendar = $tournament->getRounds();
|
||||
$roundNo = 1;
|
||||
foreach ($calendar as $round) {
|
||||
echo "Ronde: " . $roundNo . ' (' . $round->getDate()->format('Y/m/d') . PHP_EOL . ')'; $roundNo++;
|
||||
foreach($round->getGames() as $game) {
|
||||
if (!is_null($game->getResult())) {
|
||||
echo (is_null($game->getWhite())) ? "bye" : $game->getWhite()->getPlayer()->getName();
|
||||
echo " " . $game->getResult()->getValue() . " ";
|
||||
echo (is_null($game->getBlack())) ? "bye" : $game->getBlack()->getPlayer()->getName();
|
||||
echo PHP_EOL;
|
||||
}
|
||||
}
|
||||
echo PHP_EOL;
|
||||
```
|
||||
|
||||
### Getting rankings of the tournament
|
||||
```php
|
||||
<?php
|
||||
|
||||
require_once("vendor/autoload.php");
|
||||
use JeroenED\Libpairtwo\Sws;
|
||||
$sws = Sws::ReadSws("Clubcompetition.sws");
|
||||
|
||||
$tournament = $sws->getTournament();
|
||||
$rankings = $tournament->getRanking();
|
||||
$rankingNo = 1;
|
||||
foreach ($rankings as $ranking) {
|
||||
echo $rankingNo . '. ' . $ranking->getTitle()->getKey() . ' ' . $ranking->getName() . '(' . $ranking->getPoints() . '/' . $tournament->getNoOfRounds() . ')' . PHP_EOL;
|
||||
}
|
||||
echo PHP_EOL;
|
||||
```
|
Loading…
Reference in New Issue
Block a user