GithubHelp home page GithubHelp logo

mateuszkrasucki / msisdn-resolver Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 180 KB

A simple PHP package for interpreting MSISDN numbers. A simple PHP package for interpreting MSISDN numbers.

License: Other

Python 35.24% PHP 60.55% Shell 4.20%

msisdn-resolver's Introduction

msisdn-resolver

MsisdnResolver package for PHP.

A simple PHP package for interpreting MSISDN numbers.

To use, first install dependencies using composer.

Features

  1. First-tier validation. Both MSISDN started with + and without it are accepted. Whitespaces are ignored.
  2. Country code, ISO 3166-1 alpha-2 country symbol and national number identification. Bundled with verification, numbers starting with proper country code but with incorrect length are treated as not valid. For countries with shared country code (e.g. North America or Kazakhstan and Russia) mobile number patterns are checked.
  3. Mobile network operator identification. Identifcation patterns data available for Poland, Slovenia, Colombia, Algeria, South Africa, Kazakhstan and Philipines. Number portability is ignored.

Usage

$msisdn = new Msisdn('48729000000');
$msisdn->getCountryCode(); // returns country dialing code string or null if not detrmined
$msisdn->getCountryCodeString(); // returns country dialing code string or 'Unknown' if not detrmined
$msisdn->getCountryId(); // returns ISO 3166-1 alpha-2 country symbol string or null if not determined
$msisdn->getCountryIdString(); // returns ISO 3166-1 alpha-2 country symbol string or 'Unknown' if not detrmined
$msisdn->getNationalNumber(); // returns national number string or null if not determined
$msisdn->getNationalNumberString(); // returns national number string or 'Unknown' if not detrmined  
$msisdn->getMno(); // returns mobile network operator string or null if not determined
$msisdn->getMnoString(); // returns mobile network operator string or 'Unknown' if not detrmined    
$msisdn->getFullString(); // returns full identifcation string in format "MNO, Country Code, National Number, Country ID"

Adding countries

MNO patterns data for countries are stored as JSON files in /src/resources. Name of the file is just country's ISO 3166-1 alpha-2 symbol. To add MNO patterns for new countries you just have to create JSON file with the same structure and put it into 'resources' directory. ๏‚œ

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.