PHPackages                             komakino/luhn - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. komakino/luhn

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

komakino/luhn
=============

v1.0.3(10y ago)2199.7k↓61%1[1 PRs](https://github.com/komakino/luhn/pulls)1PHP

Since Jan 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/komakino/luhn)[ Packagist](https://packagist.org/packages/komakino/luhn)[ RSS](/packages/komakino-luhn/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (5)Used By (1)

Luhn
====

[](#luhn)

Luhn algorithm implementation for PHP. The Luhn algorithm is used in credit card numbers and national identity numbers.

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

[](#installation)

To add this package as a dependency to your project, simply add a dependency on `komakino/luhn` to your project's `composer.json` file.

```
    {
        "require": {
            "komakino/luhn": "*"
        }
    }
```

### Usage

[](#usage)

```
use Komakino\Luhn\Luhn;
```

#### Static methods

[](#static-methods)

*static* bool **validate**(string|int $number)

Validates a number.

```
Luhn::validate('12345678'); // returns false
Luhn::validate('87654323'); // returns true
```

*static* int **calculate**(string|int $partial\_number)

Calculates the check digit of a number.

```
Luhn::calculate('1234567'); // returns 4
Luhn::calculate('8765432'); // returns 3
```

*static* string **appendCheckDigit**(string|int $partial\_number)

Calculates the check digit and returns number with check digit appended.

```
Luhn::appendCheckDigit('1234567'); // returns 12345674
Luhn::appendCheckDigit('8765432'); // returns 87654323
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Total

4

Last Release

3816d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d2e89d042293e6d2589ecec3813563553b0a6f1ce86a777a421dd759bcb95a1?d=identicon)[komakino](/maintainers/komakino)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/komakino-luhn/health.svg)

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

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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