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)2195.5k↓28.1%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 1mo 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 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

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

3770d 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

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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