PHPackages                             mastersteelblade/discriminator - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. mastersteelblade/discriminator

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mastersteelblade/discriminator
==============================

A simple package to handle basic discriminator manipulation for user management.

v1.0.2(5y ago)010[2 issues](https://github.com/MasterSteelblade/php-discriminator/issues)MITPHPPHP &gt;=7.4CI failing

Since Feb 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/MasterSteelblade/php-discriminator)[ Packagist](https://packagist.org/packages/mastersteelblade/discriminator)[ Docs](https://github.com/MasterSteelblade/php-discriminator)[ RSS](/packages/mastersteelblade-discriminator/feed)WikiDiscussions main Synced 1mo ago

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

Discriminator
=============

[](#discriminator)

[![Latest Stable Version](https://camo.githubusercontent.com/2084ef233a08d62b291ebd7a488fa236cbc323ea67c8b21a289775db1873eb5e/68747470733a2f2f706f7365722e707567782e6f72672f6d6173746572737465656c626c6164652f6469736372696d696e61746f722f76)](//packagist.org/packages/mastersteelblade/discriminator) [![Total Downloads](https://camo.githubusercontent.com/45d71d71d43a053a15eadef587c16c3278b04ee7b34af4538bf8014292044302/68747470733a2f2f706f7365722e707567782e6f72672f6d6173746572737465656c626c6164652f6469736372696d696e61746f722f646f776e6c6f616473)](//packagist.org/packages/mastersteelblade/discriminator) [![License](https://camo.githubusercontent.com/9a7eb55f60fe27e900002caa460a7a1492eb19309d84d28b681d1df3ebbde9b3/68747470733a2f2f706f7365722e707567782e6f72672f6d6173746572737465656c626c6164652f6469736372696d696e61746f722f6c6963656e7365)](//packagist.org/packages/mastersteelblade/discriminator)

BranchGitHub ActionsCoveragemain[![Main Branch](https://github.com/MasterSteelblade/php-discriminator/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/MasterSteelblade/php-discriminator/actions/workflows/tests.yaml/badge.svg?branch=main)[![Coverage Status](https://camo.githubusercontent.com/c6b0f3ff92598a064f480479d4f1f06846a9c38cfec7b4df1428d3f4aec72ddc/68747470733a2f2f636f6465636f762e696f2f67682f4d6173746572537465656c626c6164652f7068702d6469736372696d696e61746f722f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d47343659555942464e38)](https://codecov.io/gh/MasterSteelblade/php-discriminator)dev[![Main Branch](https://github.com/MasterSteelblade/php-discriminator/actions/workflows/tests.yaml/badge.svg?branch=dev)](https://github.com/MasterSteelblade/php-discriminator/actions/workflows/tests.yaml/badge.svg?branch=dev)[![Coverage Status](https://camo.githubusercontent.com/de110de4be362b1ea7d6d942d2d02a108edaca9f1b4dfcd81dbe95f8454d51c1/68747470733a2f2f636f6465636f762e696f2f67682f4d6173746572537465656c626c6164652f7068702d6469736372696d696e61746f722f6272616e63682f6465762f67726170682f62616467652e7376673f746f6b656e3d47343659555942464e38)](https://codecov.io/gh/MasterSteelblade/php-discriminator)About
-----

[](#about)

This is a simple utility class to allow developers to implement discriminators on users, similar to Discord. This allows multiple users to share the same nickname, while allowing accounts to be tied to, for example, email addresses for uniqueness.

Installation using Composer
---------------------------

[](#installation-using-composer)

```
composer require sonata-project/google-authenticator
```

Usage
-----

[](#usage)

Discriminator is very simple to use. Below are some examples, but first, make things easier on yourself:

```
use Steelblade/Discriminator/Discriminator;
```

If you use another package that has a class of the same name, substitute the classes below with the full namespace.

### Generate a discriminator

[](#generate-a-discriminator)

Generating a discriminator can be done in one of two ways. First, you can simply create an object without passing a parameter in.

```
$discriminator = new Discriminator();
```

As no parameter has been passed, it will generate one automatically, in a range of 0 to 9999 inclusive.

You can then, if disired, get the integer value using

```
$intVal = $discriminator->get();
```

Alternatively, to generate a discriminator without instantiating, a static method exists to return an integer value.

```
$discriminator = Discriminator::generate();
```

### Loading a user from a database

[](#loading-a-user-from-a-database)

Lets say a you want to display a profile page for a user, and you retrieve their information from a database.

```
class User {
    private $ID;
    private $emailAddress;
    public $nickname;
    public $discriminator;

    ...

    public function login($emailAddress, $password) {
        // Retrieve the user from the database and verify their password.
        if ($successfulLogin) {
            $this->emailAddress = $databaseRow['email'];
            $this->nickname = $databaseRow['nickname'];
            $this->discriminator = new Discriminator($databaseRow['discriminator']);
        }
    }
}
```

The discriminator reads the numeric value, and creates itself accordingly.

### Displaying a discriminator

[](#displaying-a-discriminator)

Discriminators can be included in strings. For example:

```
return "The discriminator for $user->nickname is $user->discriminator";
// The discriminator for Master Steelblade is 0451
```

Representations of discriminators add leading zeroes to make the length consistent.

You can also retrieve the string value statically, by providing an integer value:

```
$integer = 47;
$discriminator = Discriminator::format($integer);
// Returns 0047 as a string
```

License
-------

[](#license)

Discriminator is provided under the MIT license.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~12 days

Total

3

Last Release

1884d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10645285?v=4)[Benjamin Clarke](/maintainers/MasterSteelblade)[@MasterSteelblade](https://github.com/MasterSteelblade)

---

Top Contributors

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

---

Tags

identityUser managementUsersdiscriminatoruser identitydiscriminators

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mastersteelblade-discriminator/health.svg)

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

###  Alternatives

[league/oauth2-client

OAuth 2.0 Client Library

3.8k118.6M1.2k](/packages/league-oauth2-client)[friendsofsymfony/user-bundle

Symfony FOSUserBundle

3.2k35.4M311](/packages/friendsofsymfony-user-bundle)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[onelogin/php-saml

PHP SAML Toolkit

1.3k44.0M107](/packages/onelogin-php-saml)[tomatophp/filament-users

Manage your users with a highly customizable user resource for FilamentPHP with integration of filament-shield and filament-impersonate

90102.0k7](/packages/tomatophp-filament-users)[facile-it/php-openid-client

OpenID (OIDC) Client

42592.7k7](/packages/facile-it-php-openid-client)

PHPackages © 2026

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