cleatsquad / php-pii-detector
Deterministic PII (personally identifiable information) detector and redactor for emails, phone numbers, IBANs, and credit cards
v1.0.0
2026-08-27 07:07 UTC
Requires
- php: >=8.2
- ext-mbstring: *
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
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.