PHPackages                             astronati/fantasy-football-calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. astronati/fantasy-football-calculator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

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.

2.0.0(5y ago)23.8k[1 issues](https://github.com/astronati/php-fantasy-football-calculator/issues)[1 PRs](https://github.com/astronati/php-fantasy-football-calculator/pulls)MITPHPPHP &gt;=7.4.0

Since Feb 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/astronati/php-fantasy-football-calculator)[ Packagist](https://packagist.org/packages/astronati/fantasy-football-calculator)[ RSS](/packages/astronati-fantasy-football-calculator/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (17)Used By (0)

[![Build Status](https://camo.githubusercontent.com/364e299a325c87fe3f5d85dc5c0454d1b610721271785c401bcaea7bf776d6cc/68747470733a2f2f6170692e7472617669732d63692e6f72672f617374726f6e6174692f7068702d66616e746173792d666f6f7462616c6c2d63616c63756c61746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/astronati/calculator)[![Codacy Badge](https://camo.githubusercontent.com/2a82b1906527f3af765a1951ccb399d331516d1ec62e00e270c5359afd11fe80/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3433633133323436353638343436386361623863316639646633363739353264)](https://www.codacy.com/app/astronati/php-fantasy-football-calculator?utm_source=github.com&utm_medium=referral&utm_content=astronati/php-fantasy-football-calculator&utm_campaign=Badge_Grade)[![Codacy Badge](https://camo.githubusercontent.com/53ec669d10272c997a18776a10dbdb85d1c0509fd08d1f32d7afefc968b900b8/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f436f7665726167652f3433633133323436353638343436386361623863316639646633363739353264)](https://www.codacy.com/app/astronati/php-fantasy-football-calculator?utm_source=github.com&utm_medium=referral&utm_content=astronati/php-fantasy-football-calculator&utm_campaign=Badge_Coverage)[![Dependency Status](https://camo.githubusercontent.com/0236ff256753d0c164fbe239db560ce4f97c5c75743a7166e255e18203ff843e/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3538343432653631623163333863306135643262376532312f62616467652e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/user/projects/58442e61b1c38c0a5d2b7e21)[![Latest Stable Version](https://camo.githubusercontent.com/5490ee4f645a6da81f28cd301ec7823cca072b9460cf3c90d92fd263759511bc/68747470733a2f2f706f7365722e707567782e6f72672f617374726f6e6174692f66616e746173792d666f6f7462616c6c2d63616c63756c61746f722f762f737461626c65)](https://packagist.org/packages/astronati/fantasy-football-calculator)[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](./LICENSE.md)

Fantasy Football Calculator
===========================

[](#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.

Installation
------------

[](#installation)

You can install the library and its dependencies using `composer` running:

```
$ composer require astronati/fantasy-football-calculator
```

### Usage

[](#usage)

The library returns a result:

- A [MatchResult](https://github.com/astronati/php-fantasy-football-calculator/blob/master/src/Calculator/Result/MatchResult.php)when a fantasyteam is against another one
- A simple [Result](https://github.com/astronati/php-fantasy-football-calculator/blob/master/src/Calculator/Result/Result.php)when a fantasyteam plays against all others

#### Rules

[](#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:

- [Match Rules](https://github.com/astronati/php-fantasy-football-calculator/blob/master/src/Calculator/Configuration/Rule/Match)
- [Team Rules](https://github.com/astronati/php-fantasy-football-calculator/blob/master/src/Calculator/Configuration/Rule/Team)

Each rule can be added to the Calculator configuration as shown in the example as follows.

**NOTE:**To request another rule please file a new [issue](https://github.com/astronati/php-fantasy-football-calculator/issues/new).

#### Formation and Footballers

[](#formation-and-footballers)

Calculator needs one or two formations: so developer has to provide [Formation](https://github.com/astronati/php-fantasy-football-calculator/blob/master/src/Formation/Formation.php)instances.

```
// 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)](https://github.com/astronati/php-fantasy-football-quotations-parser/blob/master/src/Model/QuotationInterface.php)instances.

Take a look at the [Footballer](https://github.com/astronati/php-fantasy-football-calculator/blob/master/example/Footballer.php)class that has been implemented in the example folder.

#### Example

[](#example)

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

```
// 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

[](#match-result)

The following snippet is extracted from the [example/sample.php](https://github.com/astronati/php-fantasy-football-calculator/blob/master/example/sampleMatch.php)file and shows how configuring a calculator in a match.

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

##### Result

[](#result)

The following snippet is extracted from the [example/sample.php](https://github.com/astronati/php-fantasy-football-calculator/blob/master/example/sample.php)file and shows how configuring a calculator when a fantasyteam plays alone or against all others.

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

Development
-----------

[](#development)

The environment requires [phpunit](https://phpunit.de/), that has been already included in the `dev-dependencies` of the `composer.json`.

### Dependencies

[](#dependencies)

To install all modules you just need to run following command:

```
$ composer install
```

### Testing

[](#testing)

Tests files are created in dedicates folders that replicate the [src](https://github.com/astronati/php-fantasy-football-calculator/tree/master/src) structure as follows:

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

```

Execute following command to run the tests suite:

```
$ composer test
```

Run what follows to see the code coverage:

```
$ composer coverage
```

License
-------

[](#license)

This package is released under the [MIT license](LICENSE.md).

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~129 days

Recently: every ~254 days

Total

15

Last Release

1954d ago

Major Versions

0.3.0 → 1.0.02018-04-06

1.2.3 → 2.0.02021-02-19

PHP version history (5 changes)0.1.0PHP &gt;=5.3.0

0.3.0PHP &gt;=5.6.0

1.0.0PHP &gt;=7.1.0

1.2.3PHP &gt;=7.2.0

2.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d2221aad4b4045aea529521b9879f8980ff7798239b23e5bc10c0f2a09f8260?d=identicon)[Andrea Stronati](/maintainers/Andrea%20Stronati)

---

Top Contributors

[![astronati](https://avatars.githubusercontent.com/u/2708431?v=4)](https://github.com/astronati "astronati (3 commits)")

---

Tags

bonuscalculatorfantacalciofantasy-footballphp7total

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/astronati-fantasy-football-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/astronati-fantasy-football-calculator/health.svg)](https://phpackages.com/packages/astronati-fantasy-football-calculator)
```

###  Alternatives

[eve/dto

Simplistic, flexible Data Transfer Object library

1214.8k](/packages/eve-dto)[elegantly/laravel-kpi

Advanced KPI for your Laravel application

174.4k1](/packages/elegantly-laravel-kpi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
