2017 © Pedro Peláez
 

library fantasy-football-calculator

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

image

astronati/fantasy-football-calculator

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  • Wednesday, July 4, 2018
  • by Andrea Stronati
  • Repository
  • 1 Watchers
  • 0 Stars
  • 180 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 41 % Grown

The README.md

Build Status Codacy Badge Codacy Badge Dependency Status Latest Stable Version MIT licensed, (*1)

Fantasy Football Calculator

This library allows user to calculate the points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one., (*2)

Installation

You can install the library and its dependencies using composer running:, (*3)

$ composer require astronati/fantasy-football-calculator

Usage

The library returns a result:, (*4)

  • A MatchResult when a fantasyteam is against another one
  • A simple Result when a fantasyteam plays against all others

Rules

Calculator can be configured with different rules in order to apply different bonus/malus to the final result. Rules can be applied to a single team or in a match context: take a look at following folders to see which bonus are supported:, (*5)

Each rule can be added to the Calculator configuration as shown in the example as follows., (*6)

NOTE: To request another rule please file a new issue., (*7)

Formation and Footballers

Calculator needs one or two formations: so developer has to provide Formation instances., (*8)

// Prepare formation
$formation = new Formation();
$formation->addFirstString(new Footballer())...

NOTE Footballer abstract class needs to be extended by developer that has to set the code property. The code property is the one provided by the Quotation(s) instances., (*9)

Take a look at the Footballer class that has been implemented in the example folder., (*10)

Example

A couple of examples are provided in order to figure out better how this library can be integrated in the own system., (*11)

// Configure calculator
$configuration = new Configuration();
$configuration
  ->addRule(RuleFactory::create(RuleFactory::BEST_DEFENDERS_RULE))
  ->addRule(RuleFactory::create(RuleFactory::HOME_RULE))
;
$calculator = new Calculator($quotations, $configuration);
Match Result

The following snippet is extracted from the example/sample.php file and shows how configuring a calculator in a match., (*12)

// Show match results...
$matchResult = $calculator->getMatchResult($formationA, $formationB);
$homeResult = $matchResult->getHomeResult();
echo '(' . $homeResult->getMagicPoints() . ' ' . $homeResult->getBonus() . ') '. $matchResult->getHomeGoals();
Result

The following snippet is extracted from the example/sample.php file and shows how configuring a calculator when a fantasyteam plays alone or against all others., (*13)

// Show single result...
$singleResult = $calculator->getSingleResult($formation);
echo $singleResult->getMagicPoints() . ' ' . $singleResult->getBonus();

Development

The environment requires phpunit, that has been already included in the dev-dependencies of the composer.json., (*14)

Dependencies

To install all modules you just need to run following command:, (*15)

$ composer install

Testing

Tests files are created in dedicates folders that replicate the src structure as follows:, (*16)

.
+-- src
|   +-- [folder-name]
|   |   +-- [file-name].php
|   ...
+-- tests
|   +-- [folder-name]
|   |   +-- [file-name]Test.php

Execute following command to run the tests suite:, (*17)

$ composer test

Run what follows to see the code coverage:, (*18)

$ composer coverage

License

This package is released under the MIT license., (*19)

The Versions

04/07 2018

dev-master

9999999-dev

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

04/07 2018

1.2.1

1.2.1.0

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

08/05 2018

1.2.0

1.2.0.0

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

08/04 2018

1.1.0

1.1.0.0

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

07/04 2018

1.0.2

1.0.2.0

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

07/04 2018

1.0.1

1.0.1.0

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

07/04 2018

dev-issues/76

dev-issues/76

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

07/04 2018

1.0.0

1.0.0.0

This library allows user to calculate the points/magic points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Andrea Stronati

19/08 2017

dev-test

dev-test

This library allows user to calculate the points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Avatar Andrea Stronati

31/12 2016

0.3.0

0.3.0.0

This library allows user to calculate the points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Avatar Andrea Stronati

13/09 2016

0.2.1

0.2.1.0

This library allows user to calculate the points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar Andrea Stronati

13/09 2016

0.2.0

0.2.0.0

This library allows user to calculate the points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar Andrea Stronati

03/09 2016

0.1.2

0.1.2.0

This library allows user to calculate the points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar Andrea Stronati

28/08 2016

0.1.1

0.1.1.0

This library allows user to calculate the points that a team has reached after a soccer match. The total can be altered through some bonus like the defense one.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar Andrea Stronati

28/02 2016

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar Andrea Stronati