Giter Club home page Giter Club logo

modulus11's Introduction

Modulus11

Modulus11 algorithm implementation for PHP. The Modulus11 algorithm is used in some bank account numbers and national identity numbers.

Installation

To add this package as a dependency to your project, simply add a dependency on komakino/modulus11 to your project's composer.json file.

    {
        "require": {
            "komakino/modulus11": "*"
        }
    }

Usage

use Komakino\Modulus11\Modulus11;

Factors

The standard factors for Modulus11 calculations are [2,3,4,5,6,7], looped. In some cases other factors are used. If your implementation requires custom factors, simply supply them as a second argument to any method.

Static methods

static bool validate(string|int $number, array $factors = null)

Validates a number.

Modulus11::validate('11223344'); // returns false
Modulus11::validate('12345674'); // returns true

static int calculate(string|int $partial_number, array $factors = null)

Calculates the check digit of a number.

Modulus11::calculate('1122334'); // returns 6
Modulus11::calculate('1234567'); // returns 4

static string appendCheckDigit(string|int $partial_number, array $factors = null)

Calculates the check digit and returns number with check digit appended.

Modulus11::appendCheckDigit('1122334'); // returns 11223346
Modulus11::appendCheckDigit('1234567'); // returns 12345674

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.