PHPackages                             kryshtalovich/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. kryshtalovich/luhn

ActiveLibrary

kryshtalovich/luhn
==================

Card numbers validator and generator

0.0.1(5y ago)38proprietaryPHP

Since Oct 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/kryshtalovich/luhn)[ Packagist](https://packagist.org/packages/kryshtalovich/luhn)[ RSS](/packages/kryshtalovich-luhn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Luhn
====

[](#luhn)

Validates and generates cards numbers against Luhn's algorithm.

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

[](#installation)

Require the package in `composer.json`

```
"require": {
    "kryshtalovich/luhn": "0.*"
  }
```

Usage
-----

[](#usage)

### Validate a card number

[](#validate-a-card-number)

```
use Kryshtalovich\Luhn\Validate;

// create validator
$validator = new Validate();

// validate against given values
$valid = $validator->isValid('2775732608516644'); //true
$noValid = $validator->isValid('2775732608516640'); //false

var_dump($valid);
var_dump($noValid);
```

Output:

```
bool(true)
bool(false)

```

### Generate a card number

[](#generate-a-card-number)

```
use Kryshtalovich\Luhn\Generate;

// create generator
$generator = new Generate();

// generate value

//defined length = 16
$randomCardNumber = $generator->generateCardNumber();

//for example American Express card with length = 15 and prefix = '3'
$amexCardNumber = $generator->generateCardNumber(15, '3');

var_dump($randomCardNumber);
var_dump($amexCardNumber);
```

Output:

```
string(16) "9241976360198403"
string(15) "336782025194042"

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

2022d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88a15d996898cc10fdd31250d7194b618ab77d3296ed1552289dcc219e9b39d1?d=identicon)[kryshtalovich](/maintainers/kryshtalovich)

---

Top Contributors

[![kryshtalovich](https://avatars.githubusercontent.com/u/48393228?v=4)](https://github.com/kryshtalovich "kryshtalovich (11 commits)")

### Embed Badge

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

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

PHPackages © 2026

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