PHPackages                             lloricode/check-digit - 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. lloricode/check-digit

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

lloricode/check-digit
=====================

v4.0.0(8mo ago)1105.7k↓45.2%1MITPHPPHP ^8.3CI passing

Since Sep 2Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/lloricode/check-digit)[ Packagist](https://packagist.org/packages/lloricode/check-digit)[ Docs](https://github.com/lloricode/check-digit)[ Fund](https://www.paypal.me/lloricode)[ Patreon](https://www.patreon.com/lloricode)[ RSS](/packages/lloricode-check-digit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (1)

Check Digit
===========

[](#check-digit)

[![Latest Version on Packagist](https://camo.githubusercontent.com/25c6a13fe5abec53f61283e55b2652aca28bbb9972fb3e24eb39efbd3e1e5f28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6c6f7269636f64652f636865636b2d64696769742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lloricode/check-digit)[![Tests](https://github.com/lloricode/check-digit/actions/workflows/run-tests.yml/badge.svg)](https://github.com/lloricode/check-digit/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/fe693bc1cb159851d2c5c2252b26107429ce99a6a43787e8fb41f791986db998/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6c6f7269636f64652f636865636b2d64696769742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lloricode/check-digit)[![codecov](https://camo.githubusercontent.com/1dfb322830763842ff8150bdbfcb2ffc3a0c7b818cd2a7aa7649fadcd80c607f/68747470733a2f2f636f6465636f762e696f2f67682f6c6c6f7269636f64652f636865636b2d64696769742f67726170682f62616467652e7376673f746f6b656e3d513731553732364a5349)](https://codecov.io/gh/lloricode/check-digit)

Check digit formula base on , and tested by

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

[](#installation)

You can install the package via composer:

```
composer require lloricode/check-digit
```

Usage
-----

[](#usage)

```
// Sample usage in testing
// tests/Feature/GenerateTest.php

use Lloricode\CheckDigit\Enums\Format;
use Lloricode\CheckDigit\Generator;

# base in https://www.gs1.org/services/check-digit-calculator

assertSame(2, Generator::new(9638527, Format::GTIN_8)->getCheckDigit());
assertSame(4, Generator::new(3216549, Format::GTIN_8)->getCheckDigit());

assertSame(2, Generator::new(91739456321, Format::GTIN_12)->getCheckDigit());
assertSame(8, Generator::new(74185245963, Format::GTIN_12)->getCheckDigit());

assertSame(3, Generator::new(629104150021, Format::GTIN_13)->getCheckDigit());
assertSame(6, Generator::new(123456789876, Format::GTIN_13)->getCheckDigit());

assertSame(6, Generator::new(7539514528423, Format::GTIN_14)->getCheckDigit());
assertSame(5, Generator::new(8563251459762, Format::GTIN_14)->getCheckDigit());

assertSame(0, Generator::new(7896541230123456, Format::GSIN)->getCheckDigit());
assertSame(3, Generator::new(7658485040650456, Format::GSIN)->getCheckDigit());

assertSame(6, Generator::new(95135623050123698, Format::SSCC)->getCheckDigit());
assertSame(7, Generator::new(87643802105978513, Format::SSCC)->getCheckDigit());

// get generated value
assertSame('876438021059785137', Generator::new(87643802105978513, Format::SSCC)->getValue());

// starts with zero
assertSame(7, Generator::new('0012345', Format::GTIN_8)->getCheckDigit());
assertSame(5, Generator::new('00123456789', Format::GTIN_12)->getCheckDigit());
assertSame(5, Generator::new('001234567890', Format::GTIN_13)->getCheckDigit());
assertSame(2, Generator::new('0012345678901', Format::GTIN_14)->getCheckDigit());
assertSame(3, Generator::new('0012345678901234', Format::GSIN)->getCheckDigit());
assertSame(2, Generator::new('00123456789012345', Format::SSCC)->getCheckDigit());
```

Testing
-------

[](#testing)

```
vendor/bin/pest
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lloric Mayuga Garcia](https://github.com/lloricode)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance75

Regular maintenance activity

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 87.6% 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 ~152 days

Recently: every ~253 days

Total

13

Last Release

261d ago

Major Versions

v1.1.0 → v2.0.02022-11-24

v2.1.0 → v3.0.02023-10-09

v3.0.1 → v4.0.02025-08-31

PHP version history (5 changes)v1.0.0PHP ^7.4

v1.0.5PHP ^7.4|^8.0

v1.1.0PHP ^8.0

v2.0.0PHP ^8.1

v4.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/1cdb70b3c1af4426f87d055490f2337dae57cb3bd884b013c5c068f8ee24fab1?d=identicon)[lloricode](/maintainers/lloricode)

---

Top Contributors

[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (113 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![bernardofm](https://avatars.githubusercontent.com/u/26308295?v=4)](https://github.com/bernardofm "bernardofm (2 commits)")

---

Tags

calculatorcheck-digithacktoberfestphplloricodecheck-digit

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lloricode-check-digit/health.svg)

```
[![Health](https://phpackages.com/badges/lloricode-check-digit/health.svg)](https://phpackages.com/packages/lloricode-check-digit)
```

###  Alternatives

[hyperf/crontab

A crontab component for Hyperf.

131.6M62](/packages/hyperf-crontab)

PHPackages © 2026

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