PHPackages                             vgpastor/discounts-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. vgpastor/discounts-calculator

ActiveLibrary

vgpastor/discounts-calculator
=============================

Helper library to manage different types of discounts and calculate the relational data

1.0.0(3y ago)12MITPHPPHP ^8.1

Since Oct 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/vgpastor/DiscountsCalculator)[ Packagist](https://packagist.org/packages/vgpastor/discounts-calculator)[ RSS](/packages/vgpastor-discounts-calculator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

DiscountsCalculator
===================

[](#discountscalculator)

Helper library for calculating discounts in a application.

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

[](#installation)

This library are developed to PHP 8.1, use Enum so it's not possible using in previously versions, if you like you can put a PR to make compatible with previous versions.. `composer install vgpastor/discounts-calculator`

Usage
-----

[](#usage)

Yo can see how to use in example.php file.

Required parameter are

- $type: Type of discount. Can be 'percentage' or 'amount' and based in base amount or in total amount (see DiscountTypeEnum)
- $base (float) - Base price
- $discount (float) - Discount percentage or amount

Optional parameters are

- $tax (float) - Tax percentage By default is 0%
- $precision (int) - Precision of the result. By default is 2
- $roundingMode (int) - Rounding mode. By default is PHP\_ROUND\_HALF\_UP

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1312d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fdc850eaa3e2742ef573a357e4147ac7f0beee207c9488eb0e514a1f3fc38d1e?d=identicon)[vgpastor08@gmail.com](/maintainers/vgpastor08@gmail.com)

---

Top Contributors

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

---

Tags

discountdiscountsphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vgpastor-discounts-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/vgpastor-discounts-calculator/health.svg)](https://phpackages.com/packages/vgpastor-discounts-calculator)
```

PHPackages © 2026

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