PHPackages                             coatesap/credit-card-validator - 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. coatesap/credit-card-validator

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

coatesap/credit-card-validator
==============================

A simple PHP class for validating credit/debit card details

v2.0(11y ago)82247[1 issues](https://github.com/coatesap/credit-card-validator/issues)[1 PRs](https://github.com/coatesap/credit-card-validator/pulls)MITPHP

Since Dec 2Pushed 9y ago2 watchersCompare

[ Source](https://github.com/coatesap/credit-card-validator)[ Packagist](https://packagist.org/packages/coatesap/credit-card-validator)[ Docs](https://github.com/coatesap/credit-card-validator)[ RSS](/packages/coatesap-credit-card-validator/feed)WikiDiscussions master Synced today

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

Credit Card Validator
=====================

[](#credit-card-validator)

A simple PHP class for preparing and validating credit/debit card details. Typically this takes place before they are passed to a payment gateway for processing.

Example Usage
-------------

[](#example-usage)

```
require '../vendor/autoload.php';

$cardDetails = array(
    'number' =>'4929000000006',
    'expiryYear' => 2013,
    'expiryMonth' => 5,
    'code' => '123'
);

$card = new Coatesap\Payment\Card();
$card->populate($cardDetails);

if (!$card->isValid($message)) {
    // show error message (set by reference)
    echo 'There is a problem with your card details: ' . $message;
} else {
    // get the prepped, validated card data as an array
    $cardData = $card->toArray();
    // send $cardData to payment gateway
}
```

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

[](#installation)

The credit card class can be installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file:

```
{
    "require": {
        "coatesap/credit-card-validator": "~2.0"
    }
}
```

Data preparation
----------------

[](#data-preparation)

This class does some simple preparation of your card data. This includes removing non-numeric characters, including spaces, from:

- The card number
- The CVC/CV2 value
- The card expiry date

Validation Checks
-----------------

[](#validation-checks)

This class also checks:

- That the card hasn't expired
- A valid CVC/CV2 security code has been supplied
- The card number passes the Luhn check

###  Health Score

32

—

LowBetter than 74% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

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

Total

4

Last Release

4130d ago

Major Versions

v1.2 → v2.02014-12-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/ff62e9d8c1b4833b67d772a5273bff97c4e2f10ff79eef9efcfb67fb1bc4a5d4?d=identicon)[coatesap](/maintainers/coatesap)

---

Top Contributors

[![silici0](https://avatars.githubusercontent.com/u/61994?v=4)](https://github.com/silici0 "silici0 (8 commits)")

### Embed Badge

![Health badge](/badges/coatesap-credit-card-validator/health.svg)

```
[![Health](https://phpackages.com/badges/coatesap-credit-card-validator/health.svg)](https://phpackages.com/packages/coatesap-credit-card-validator)
```

###  Alternatives

[webmozart/assert

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

7.7k882.5M1.1k](/packages/webmozart-assert)[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k479.5M573](/packages/composer-semver)[laminas/laminas-escaper

Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs

21986.9M121](/packages/laminas-laminas-escaper)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.2M70](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5245.4M14](/packages/stevebauman-purify)[ddeboer/vatin

Validate VAT identification numbers

1422.9M8](/packages/ddeboer-vatin)

PHPackages © 2026

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