Coder Social home page Coder Social logo

fide-data's Introduction

FIDE

Library for processing open data published by FIDE for PHP

Build Status

Features

  • Download all player rating XML files published by FIDE
  • Read and parse player rating XML files

Documentation

Installation

Use Composer to install the library for your project:

composer require tegenterter/fide-data

Basic Usage

<?php

require __DIR__ . '/vendor/autoload.php';

// Download particular rating file from https://ratings.fide.com/download_lists.phtml
$client = new \FideData\Http\RatingXmlDownloader(__DIR__);
$path = $client->download(\FideData\Enum\RatingType::STANDARD, 2020, 12);

// Read and parse the rating file
$rating = new \FideData\PlayerRating($path);

/** @var \FideData\Structure\Player $player */
foreach ($rating->process() as $player) {
    // Get array representation of the player object
    $array = $player->toArray();

    echo json_encode($array, JSON_PRETTY_PRINT) . PHP_EOL;
    /**
    {
        "fideId": 1503014,
        "name": "Carlsen, Magnus",
        "federation": "NOR",
        "birthYear": 1990,
        "sex": "M",
        "title": "GM",
        "standardRating": {
            "type": "standard",
            "rating": 2862,
            "k": 10
        },
        "rapidRating": null,
        "blitzRating": null,
        "active": true
    } 
    */
}

Testing

The library is covered by unit tests using PHPUnit. You can use the following Composer script to run them:

composer run test

fide-data's People

Contributors

tegenterter avatar eydun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.