{"id":15827810,"url":"https://github.com/phillarmonic/cpf-cnpj","last_synced_at":"2025-04-01T18:30:36.424Z","repository":{"id":257802585,"uuid":"863971254","full_name":"Phillarmonic/cpf-cnpj","owner":"Phillarmonic","description":"Validators for CPF and CNPJ for PHP","archived":false,"fork":false,"pushed_at":"2024-09-27T10:43:37.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-12T10:31:19.646Z","etag":null,"topics":["cnpj","cnpj-validator","cpf","cpf-validador","php","php8","validation"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Phillarmonic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-27T08:53:35.000Z","updated_at":"2024-10-03T11:01:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"8e9e0176-50b4-462b-aafb-5abc28c066f8","html_url":"https://github.com/Phillarmonic/cpf-cnpj","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"6be4de6e92a2d0be1f7ec28386a7239c144dcfc7"},"previous_names":["phillarmonic/cpf-cnpj"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phillarmonic%2Fcpf-cnpj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phillarmonic%2Fcpf-cnpj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phillarmonic%2Fcpf-cnpj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Phillarmonic%2Fcpf-cnpj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Phillarmonic","download_url":"https://codeload.github.com/Phillarmonic/cpf-cnpj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222749363,"owners_count":17031913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnpj","cnpj-validator","cpf","cpf-validador","php","php8","validation"],"created_at":"2024-10-05T10:09:19.415Z","updated_at":"2024-11-02T17:08:02.249Z","avatar_url":"https://github.com/Phillarmonic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phillarmonic/cpf-cnpj\n\nA PHP library for validating and formatting CPF and CNPJ numbers from Brazil.\n\n## Installation\n\nYou can install this library using Composer. Run the following command in your project directory:\n\n```bash\ncomposer require phillarmonic/cpf-cnpj\n```\n\n## Usage\n\n### Validating CPF Numbers\n\nTo validate a CPF number:\n\n```php\nuse Phillarmonic\\CpfCnpj\\CPF;\n\n$cpf = new CPF('123.456.789-09');\nif ($cpf-\u003eisValid()) {\n    echo \"The CPF is valid.\";\n} else {\n    echo \"The CPF is not valid.\";\n}\n```\n\n### Formatting CPF Numbers\n\nTo format a valid CPF number:\n\n```php\nuse Phillarmonic\\CpfCnpj\\CPF;\n\n$cpf = new CPF('12345678909');\n$formattedCpf = $cpf-\u003eformat();\n\nif ($formattedCpf !== false) {\n    echo \"Formatted CPF: \" . $formattedCpf; // Outputs: 123.456.789-09\n} else {\n    echo \"Invalid CPF, unable to format.\";\n}\n```\n\n### Validating CNPJ Numbers\n\nTo validate a CNPJ number:\n\n```php\nuse Phillarmonic\\CpfCnpj\\CNPJ;\n\n$cnpj = new CNPJ('12.345.678/0001-95');\nif ($cnpj-\u003eisValid()) {\n    echo \"The CNPJ is valid.\";\n} else {\n    echo \"The CNPJ is not valid.\";\n}\n```\n\n### Formatting CNPJ Numbers\n\nTo format a valid CNPJ number:\n\n```php\nuse Phillarmonic\\CpfCnpj\\CNPJ;\n\n$cnpj = new CNPJ('12345678000195');\n$formattedCnpj = $cnpj-\u003eformat();\n\nif ($formattedCnpj !== false) {\n    echo \"Formatted CNPJ: \" . $formattedCnpj; // Outputs: 12.345.678/0001-95\n} else {\n    echo \"Invalid CNPJ, unable to format.\";\n}\n```\n\n## Important Notes\n\n1. The library automatically removes any non-digit characters from the input, so you can pass formatted or unformatted numbers.\n2. The `isValid()` method checks for:\n    - Correct length (11 digits for CPF, 14 digits for CNPJ)\n    - Not in the blacklist of known invalid numbers\n    - Validity of check digits\n3. The `format()` method returns `false` if the number is invalid.\n\n## Error Handling\n\nThe library doesn't throw exceptions. Instead, it returns `false` or fails silently in case of invalid input. Always check the return value of `isValid()` before using the number, and check if `format()` returns `false` before using the formatted result.\n\n## Contributing\n\nIf you'd like to contribute to this project, please submit a pull request on the GitHub repository.\n\n## License\n\nThis library is open-sourced software licensed under the MIT license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphillarmonic%2Fcpf-cnpj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphillarmonic%2Fcpf-cnpj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphillarmonic%2Fcpf-cnpj/lists"}