PHPackages                             dnkmdg/price-tidy - 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. dnkmdg/price-tidy

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

dnkmdg/price-tidy
=================

Seamless price rounding and adjustment

1.0(1y ago)183MITPHPPHP &gt;=8.2

Since Nov 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dnkmdg/price-tidy)[ Packagist](https://packagist.org/packages/dnkmdg/price-tidy)[ RSS](/packages/dnkmdg-price-tidy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

PriceTidy
=========

[](#pricetidy)

[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/eba0e4d887068130682f78eb43700a2ff14a2d73eb8e3381e560a7c18be8e0c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646e6b6d64672f70726963652d746964792f7068702e796d6c3f6c6162656c3d7465737473)](https://camo.githubusercontent.com/eba0e4d887068130682f78eb43700a2ff14a2d73eb8e3381e560a7c18be8e0c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646e6b6d64672f70726963652d746964792f7068702e796d6c3f6c6162656c3d7465737473)[![GitHub Release](https://camo.githubusercontent.com/3abd02c18034144f6698e5a806bf64115af96ed0837238e2737013f9bab4e3a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f646e6b6d64672f70726963652d74696479)](https://camo.githubusercontent.com/3abd02c18034144f6698e5a806bf64115af96ed0837238e2737013f9bab4e3a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f646e6b6d64672f70726963652d74696479)[![GitHub Downloads (all assets, all releases)](https://camo.githubusercontent.com/9b75adc89f819d63b5fe05c8f767ca2e8271d72d14b7f009a27be9cbbeb54015/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f646e6b6d64672f70726963652d746964792f746f74616c3f636f6c6f723d626c7565)](https://camo.githubusercontent.com/9b75adc89f819d63b5fe05c8f767ca2e8271d72d14b7f009a27be9cbbeb54015/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f646e6b6d64672f70726963652d746964792f746f74616c3f636f6c6f723d626c7565)

PriceTidy is a PHP library for seamless price rounding and adjustment using various rounding strategies.

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

[](#installation)

To install PriceTidy, you can use Composer:

```
composer require dnkmdg/price-tidy
```

Usage
-----

[](#usage)

Here's a basic example of how to use PriceTidy:

```
use Dnkmdg\PriceTidy\PriceTidy;
use Dnkmdg\PriceTidy\Strategies\RoundUpToNearestIntegerStrategy;

$priceTidy = new PriceTidy(10.5, 1.25, new RoundUpToNearestIntegerStrategy());
echo $priceTidy->priceIncVat; // Output: 14
```

Rounding Strategies
-------------------

[](#rounding-strategies)

PriceTidy supports multiple rounding strategies:

- `RoundUpToNearestIntegerStrategy`: Rounds up to the nearest integer.
- `RoundUpToNearestNineStrategy`: Rounds up to the nearest nine.
- `RoundUpToNearestTenStrategy`: Rounds up to the nearest ten.
- `RoundUpToNearestHundredStrategy`: Rounds up to the nearest hundred.
- `EuroStrategy`: Example of a custom rounding strategy.

Example
-------

[](#example)

```
use Dnkmdg\PriceTidy\PriceTidy;
use Dnkmdg\PriceTidy\Strategies\RoundUpToNearestTenStrategy;

$priceTidy = new PriceTidy(10.5, 1.25, new RoundUpToNearestTenStrategy());
echo $priceTidy->priceIncVat; // Output: 20
```

Custom Rounding Strategy
------------------------

[](#custom-rounding-strategy)

You can create your own custom rounding strategy by extending the `RoundingStrategy` abstract class and implementing the `round` method.

Here's an example of a custom rounding strategy that rounds to the nearest five:

```
namespace Dnkmdg\PriceTidy\Strategies;

class RoundToNearestFiveStrategy extends RoundingStrategy
{
    public function round(float $value): float
    {
        return round($value / 5) * 5;
    }
}
```

To use this custom strategy with PriceTidy:

```
use Dnkmdg\PriceTidy\PriceTidy;
use Dnkmdg\PriceTidy\Strategies\RoundToNearestFiveStrategy;

$priceTidy = new PriceTidy(10.5, 1.25, new RoundToNearestFiveStrategy());
echo $priceTidy->priceIncVat; // Output will be 15
```

Running Tests
-------------

[](#running-tests)

To run the tests, use PHPUnit:

```
vendor/bin/pest
```

License
-------

[](#license)

This project is licensed under the MIT License.

Authors
-------

[](#authors)

- Daniel Källstrand Modig ()

Contributing
------------

[](#contributing)

Contributions are welcome! Please open an issue or submit a pull request.

This project is licensed under the MIT License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Every ~0 days

Total

2

Last Release

557d ago

Major Versions

0.1 → 1.02024-11-01

PHP version history (2 changes)0.1PHP &gt;=8

1.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1211068622ff1f6917114b6e558bf684a0066952f094060e16d5738b1fbf42cc?d=identicon)[dnkmdg](/maintainers/dnkmdg)

---

Top Contributors

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

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/dnkmdg-price-tidy/health.svg)

```
[![Health](https://phpackages.com/badges/dnkmdg-price-tidy/health.svg)](https://phpackages.com/packages/dnkmdg-price-tidy)
```

###  Alternatives

[jeroen/rewindable-generator

Provides a simple adapter to make generators rewindable

1655.4k2](/packages/jeroen-rewindable-generator)

PHPackages © 2026

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