PHPackages                             w5n/dicen - 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. w5n/dicen

ActiveLibrary

w5n/dicen
=========

Parse complex dice rolls from strings.

0.3(5y ago)09[1 PRs](https://github.com/waldson/dicen/pulls)MITPHPPHP &gt;=7.3

Since Dec 8Pushed 5y ago1 watchersCompare

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

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

Dicen
=====

[](#dicen)

Parser for dice rolls.

Instalation
-----------

[](#instalation)

```
composer install w5n/dicen

```

Usage
-----

[](#usage)

```
use W5n\Dicen\DefaultRandomGenerator;
use W5n\Dicen\DiceEngine;
use W5n\Dicen\DiceParser;

$parser          = new DiceParser();
$randomGenerator = new DefaultRandomGenerator();
$engine          = new DiceEngine($parser, $randomGenerator);

// Dice mode
$engine->roll('5d4+3');

// Math mode
$engine->roll('120+10*33-45');

// Mixed mode
$engine->roll('2d6-4+45-2d10+8');

// Invalid roll throws exception
try {
    $engine->roll('invalid');
} catch (\Exception $ex) {
    //...
}

// Syntax tree
$ast = $parser->parse('2d6+25-1d4-1');
```

TO-DO
-----

[](#to-do)

- Use a custom exception
- Exploding Dices
- Keep or Drop some highest/lowest dices
- Show roll details

References
----------

[](#references)

- [Roll20's dice reference](https://wiki.roll20.net/Dice_Reference)
- [Shunting-yard algorithm](https://en.wikipedia.org/wiki/Shunting-yard_algorithm)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

3

Last Release

1980d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1339cbf6d87d02038fcec2fb6ab0471a5b59144b88fb8d6e7afafb7ac015dad3?d=identicon)[waldson](/maintainers/waldson)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/w5n-dicen/health.svg)

```
[![Health](https://phpackages.com/badges/w5n-dicen/health.svg)](https://phpackages.com/packages/w5n-dicen)
```

PHPackages © 2026

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