{"id":28393663,"url":"https://github.com/thewebsolver/luhn-algorithm","last_synced_at":"2025-06-26T11:32:09.227Z","repository":{"id":256601042,"uuid":"851699521","full_name":"TheWebSolver/luhn-algorithm","owner":"TheWebSolver","description":"PHP library to validate digits such as Credit Card Number, IMEI number, etc. with Luhn Algorithm","archived":false,"fork":false,"pushed_at":"2025-02-27T08:39:33.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-01T03:39:38.760Z","etag":null,"topics":["bank-card","credit-card","debit-card","imei","imei-validation","luhn","luhn-algorithm","luhn-checkdigit","luhn-checksum","luhn-php","luhn-validation","payment-card","validation","validator"],"latest_commit_sha":null,"homepage":"https://github.com/TheWebSolver/luhn-algorithm","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheWebSolver.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-03T15:06:00.000Z","updated_at":"2025-02-27T08:39:37.000Z","dependencies_parsed_at":"2024-09-12T01:43:01.961Z","dependency_job_id":"61b641d9-23f2-4f0e-a2fd-d4d2a9db4bfa","html_url":"https://github.com/TheWebSolver/luhn-algorithm","commit_stats":null,"previous_names":["thewebsolver/luhn-algorithm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheWebSolver/luhn-algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheWebSolver%2Fluhn-algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheWebSolver%2Fluhn-algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheWebSolver%2Fluhn-algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheWebSolver%2Fluhn-algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheWebSolver","download_url":"https://codeload.github.com/TheWebSolver/luhn-algorithm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheWebSolver%2Fluhn-algorithm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262056130,"owners_count":23251607,"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":["bank-card","credit-card","debit-card","imei","imei-validation","luhn","luhn-algorithm","luhn-checkdigit","luhn-checksum","luhn-php","luhn-validation","payment-card","validation","validator"],"created_at":"2025-05-31T16:39:15.350Z","updated_at":"2025-06-26T11:32:09.204Z","avatar_url":"https://github.com/TheWebSolver.png","language":"PHP","readme":"📦 This package is a sub-repo split of a PHP Validator which is currently under development.\n\n✨ This can also be installed as a dependency for [Payment Card](https://github.com/thewebsolver/payment-card) library to validate Debit/Credit Cards.\n\n# Introduction\n\nLuhn Algorithm to validate Payment Cards, IMEI numbers and other digits that needs Luhn validation.\n\n## Usage\n\n### Install\n\n```sh\ncomposer require thewebsolver/luhn-algorithm\n```\n\n### Validate\n\nValidation can be performed using any of the three OPTIONS presented below:\n\n```php\nuse TheWebSolver\\Codegarage\\Validator\\LuhnAlgorithm;\n\n// OPTION 1: Value passing via constructor.\n$luhn     = new LuhnAlgorithm(79927398713);\n$isValid  = $luhn-\u003eisValid();  // true\n$checksum = $luhn-\u003echecksum(); // 70\n\n// OPTION 2: Value passing via invocable class.\n$luhn     = new LuhnAlgorithm();\n$isValid  = $luhn(79927398713); // true\n$checksum = $luhn-\u003echecksum();  // 70\n\n// OPTION 3: Value passing via static method. In this case, There is no\n// instance stored in memory \u0026 can only be used for one-off validation.\n$isValid = LuhnAlgorithm::validate(79927398713); // true\n```\n\n### Debug\n\nFrom above [Validation](#validate) example, we can debug more details about the validation status and various state of each number when checkum was calculated.\n\n```php\nvar_dump( $luhn ); // Input value was: 79927398713\n\n// The debug output.\narray(4) {\n  'isValid' =\u003e\n  bool(true)\n  'digits' =\u003e\n  int(79947697723)\n  'checksum' =\u003e\n  int(70)\n  'state' =\u003e\n  array(11) {\n    [0] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(false)\n      'result' =\u003e\n      int(7)\n    }\n    [1] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(true)\n      'result' =\u003e\n      int(9)\n    }\n    [2] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(false)\n      'result' =\u003e\n      int(9)\n    }\n    [3] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(true)\n      'result' =\u003e\n      int(4)\n    }\n    [4] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(false)\n      'result' =\u003e\n      int(7)\n    }\n    [5] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(true)\n      'result' =\u003e\n      int(6)\n    }\n    [6] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(false)\n      'result' =\u003e\n      int(9)\n    }\n    [7] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(true)\n      'result' =\u003e\n      int(7)\n    }\n    [8] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(false)\n      'result' =\u003e\n      int(7)\n    }\n    [9] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(true)\n      'result' =\u003e\n      int(2)\n    }\n    [10] =\u003e\n    array(2) {\n      'doubled' =\u003e\n      bool(false)\n      'result' =\u003e\n      int(3)\n    }\n  }\n}\n```\n\n# Composition\n\nThe [Luhn Algorithm](Src/LuhnAlgorithm.php) class is actually composed by using [Luhn](Src/Luhn.php) trait. This trait can be used elsewhere in separate class defined in your project or modify validation methods as per the project's requirement (latter of which seem unnecessary though).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewebsolver%2Fluhn-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthewebsolver%2Fluhn-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewebsolver%2Fluhn-algorithm/lists"}