Coder Social home page Coder Social logo

msisdn's Introduction

msisdn

This is a basic PHP 7 package that basically enforces the standard number format of 2547 prrefix of Kenyan based mobile numbers. The clean method also checks for the validity of an MSISDN number if given as 07XX, 7XX or 2547XX formats. Prefixes are updated courtesy of https://en.wikipedia.org/wiki/Telephone_numbers_in_Kenya

Installation

Download the package zip, extract and run

composer install

Alternatively run:

composer require allan/msisdn

Examples

Get Channel

use Msisdn\Utility;
include 'vendor/autoload.php';

var_dump(Utility::getMobileNetworkOperator("+254 720 000000")); // string(9) "Safaricom"
var_dump(Utility::getMobileNetworkOperator("0720000000")); // string(9) "Safaricom"
var_dump(Utility::getMobileNetworkOperator("720000000")); // string(9) "Safaricom"

Clean MSISDN

use Msisdn\Utility;
include 'vendor/autoload.php';

var_dump(Utility::clean("+254 720 000000")); // int(254720000000)
var_dump(Utility::clean("0720000000")); // int(254720000000)
var_dump(Utility::clean("720000000")); // int(254720000000)
var_dump(Utility::clean("7200022")); // int(-1) invalid MSISDN format that cannot be sanitized

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.