cleatsquad/php-pii-detector

Deterministic PII (personally identifiable information) detector and redactor for emails, phone numbers, IBANs, and credit cards

Maintainers

Package info

github.com/CleatSquad/php-pii-detector

pkg:composer/cleatsquad/php-pii-detector

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v1.0.0 2026-08-27 07:07 UTC

This package is not auto-updated.

Last update: 2026-08-28 05:33:07 UTC


README

Deterministic PII (personally identifiable information) detector and redactor in pure PHP.

Detects and redacts:

  • Email addresses
  • Phone numbers (international + formats, French formats)
  • IBANs (validated with ISO 7064 mod-97 checksum)
  • Credit card numbers (validated with Luhn algorithm)

Installation

composer require cleatsquad/php-pii-detector

Usage

use CleatSquad\PiiDetector\PiiDetector;

$detector = new PiiDetector();

// Redaction
$text = 'Contact me at john.doe@example.com or +33 6 12 34 56 78';
$clean = $detector->redact($text);
// "Contact me at [redacted] or [redacted]"

// Inspection (does not return values)
$matches = $detector->detect($text);
foreach ($matches as $match) {
    echo $match->type->value . ' at offset ' . $match->offset . ' length ' . $match->length . PHP_EOL;
}

Testing

composer install
composer test      # PHPUnit
composer analyse   # PHPStan, max level

License

MIT. See LICENSE.