PHPackages                             lacus/cpf-dv - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lacus/cpf-dv

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lacus/cpf-dv
============

Utility to calculate check digits on CPF (Brazilian Individual's Taxpayer ID)

1.0.0(1mo ago)00MITPHPPHP ^8.2

Since Mar 20Pushed 1mo agoCompare

[ Source](https://github.com/LacusSolutions/br-utils-php_cpf-dv)[ Packagist](https://packagist.org/packages/lacus/cpf-dv)[ Docs](https://cpf-utils.vercel.app/)[ RSS](/packages/lacus-cpf-dv/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

[![cpf-dv for PHP](https://camo.githubusercontent.com/96803fa1e852a1ad98536f53d78061930f557e3ad5e021323b4085b1815685d3/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f6370662d64762e6a7067)](https://camo.githubusercontent.com/96803fa1e852a1ad98536f53d78061930f557e3ad5e021323b4085b1815685d3/68747470733a2f2f62722d7574696c732e76657263656c2e6170702f696d672f636f7665725f6370662d64762e6a7067)

[![Packagist Version](https://camo.githubusercontent.com/df88e4c6eb2aa27605bcca28883a9b6217b471ff8a346a734eec1c9fb861b96b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c616375732f6370662d6476)](https://packagist.org/packages/lacus/cpf-dv)[![Packagist Downloads](https://camo.githubusercontent.com/8ee7b091e46679af2674970819aabb80c94216679531786ed0d83751ea2229ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c616375732f6370662d6476)](https://packagist.org/packages/lacus/cpf-dv)[![PHP Version](https://camo.githubusercontent.com/4d6f1d2928a616df5cb7adcef523e419a22b8c28c39e0bc7310b67df0001b1a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c616375732f6370662d6476)](https://www.php.net/)[![Test Status](https://camo.githubusercontent.com/bc71a889730b33757624a7665d324206586beb2c64e6a2d2d32852e2b30f1df1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4c61637573536f6c7574696f6e732f62722d7574696c732d7068702f63692e796d6c3f6c6162656c3d63692f6364)](https://github.com/LacusSolutions/br-utils-php/actions)[![Last Update Date](https://camo.githubusercontent.com/3de9411599aeb23885d20d61de36d9b02a1b43618d8b4360e57fd371469c61cb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f4c61637573536f6c7574696f6e732f62722d7574696c732d706870)](https://github.com/LacusSolutions/br-utils-php)[![Project License](https://camo.githubusercontent.com/3831eac41446c923d630ebf80bfc848f862c79619ee4814821521ccf13dfef2a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4c61637573536f6c7574696f6e732f62722d7574696c732d706870)](https://github.com/LacusSolutions/br-utils-php/blob/main/LICENSE)

> 🌎 [Acessar documentação em português](https://github.com/LacusSolutions/br-utils-php/blob/main/packages/cpf-dv/README.pt.md)

A PHP utility to calculate check digits on CPF (Brazilian Individual's Taxpayer ID).

PHP Support
-----------

[](#php-support)

[![PHP 8.2](https://camo.githubusercontent.com/6dab1427c2636572a765f9e0f332c0665ce863cbc46cece88aa44f747132c260/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/6dab1427c2636572a765f9e0f332c0665ce863cbc46cece88aa44f747132c260/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHP 8.3](https://camo.githubusercontent.com/2bace8bb56a21d62a4c1c2e2018eb2e83eff46e07cab21c26ca42feda0bdd46e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/2bace8bb56a21d62a4c1c2e2018eb2e83eff46e07cab21c26ca42feda0bdd46e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHP 8.4](https://camo.githubusercontent.com/cf871f594e557c5b9ae8715a2b7207b9b73686ee83156cd0308489979d0d84e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/cf871f594e557c5b9ae8715a2b7207b9b73686ee83156cd0308489979d0d84e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHP 8.5](https://camo.githubusercontent.com/38189c74fa19d38a84282702897dcd5bf0e54f8ee6be5cb02aa9a3a1f5711862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/38189c74fa19d38a84282702897dcd5bf0e54f8ee6be5cb02aa9a3a1f5711862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)Passing ✔Passing ✔Passing ✔Passing ✔Features
--------

[](#features)

- ✅ **Flexible input**: Accepts `string` or `array` of strings
- ✅ **Format agnostic**: Automatically strips non-numeric characters from string input
- ✅ **Auto-expansion**: Multi-character strings in arrays are expanded to individual digits
- ✅ **Lazy evaluation**: Check digits are calculated only when accessed (via properties)
- ✅ **Caching**: Calculated values are cached for subsequent access
- ✅ **Property-style API**: `first`, `second`, `both`, `cpf` (via magic `__get`)
- ✅ **Minimal dependencies**: Only [`lacus/utils`](https://packagist.org/packages/lacus/utils)
- ✅ **Error handling**: Specific types for type, length, and invalid CPF scenarios (`TypeError` vs `Exception` semantics)

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

[](#installation)

```
# using Composer
$ composer require lacus/cpf-dv
```

Quick Start
-----------

[](#quick-start)

```
