dwr/lottoclient-bundle

Symfony2 bundle which helps connect to polish lotto server (Totalizator sportowy).

1.0 2015-08-06 21:27 UTC

This package is not auto-updated.

Last update: 2024-11-09 19:17:09 UTC


README

Build Status Scrutinizer Code Quality

DwrLottoClient

This bundle helps to take results from polish national lottery

Installation

Installation is a quick 3 steps process:

  1. Download DwrLottoClientBundle using composer.
  2. Enable the Bundle.
  3. Use bundle in your controller.

Step 1: Download DwrAvatarBundle using composer

Add DwrGlobalWeatherBundle in your composer.json:

{
    "require": {
        "dwr/lottoclient-bundle": "1.0"
    }
}

Download the bundle by running the command:

$ php composer.phar require dwr/lottoclient-bundle

Composer will install the bundle into your project's vendor/dwr/lottoclient-bundle directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

//app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Dwr\LottoClientBundle\DwrLottoClientBundle(),
    );
}

Step 3: Use bundle in your controller

    
    use Dwr\LottoClientBundle\Service\LottoClient; //don't forget add this line above class declaration
   

    /**
     * @Route("/", name="homepage")
     */
    public function indexAction()
    {

        $lotto = $this->get('dwr_lotto_client');
        $resultsDL = $lotto->getRecentlyResults(LottoClient::DUZY_LOTEK, 1); //takes last result from Duży lotek
        $resultsK  = $lotto->getRecentlyResults(LottoClient::KASKADA, 5); //takes 5 recently results from Kaskada
        
        var_dump($resultsDL);
        var_dump($resultsK);

        $date = new \DateTime('2014-10-10');
        $resultMINI = $lotto->getResultsByDate($date, LottoClient::MINI_LOTEK, 2); //takes 2 recently results from giving date for Mini Lotek
        $resultMULTI = $lotto->getResultsByDate($date, LottoClient::MULTI_LOTEK, 3); //takes 3 recently results from giving date for Multi Lotek

        var_dump($resultMINI);
        var_dump($resultMULTI);

        return $this->render('default/index.html.twig');
    }

Congratulations! You're ready to embed lotto results in your symfony2 application.

Usage

Add this in your controller:

    use Dwr\LottoClientBundle\Service\LottoClient; //don't forget add this line above class declaration

    /**
     * @Route("/", name="homepage")
     */
    public function indexAction()
    {

        $lotto = $this->get('dwr_lotto_client');
        
        /**
         * In order to take last result from Duży lotek pass 1 as a second argument for getRecentlyResults method.
         * Maximum you can take 10 recently results.
         */
        $resultsDL = $lotto->getRecentlyResults(LottoClient::DUZY_LOTEK, 1);
        var_dump($resultsDL); 
        
        /**
         * In order to take archive results use getResultsByDate method.
         * Specify date (e.g. new \DateTime('2014-10-10')) and pass it as first argument.
         */
        $date = new \DateTime('2014-10-10');
        $resultMINI = $lotto->getResultsByDate($date, LottoClient::MINI_LOTEK, 2);
        var_dump($resultMINI);
    }

Available lottery types:

LottoClient::DUZY_LOTEK
LottoClient::MINI_LOTEK
LottoClient::MULTI_LOTEK
LottoClient::JOKER
LottoClient::KASKADA