GithubHelp home page GithubHelp logo

jenesiszw / phone_lib Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 11 KB

a classic phone number handling library based on libphonenumber for PHP made by https://github.com/giggsey

Home Page: https://github.com/jenesiszw/phone_lib

PHP 100.00%
phone-number phone-number-information phone-number-validation php

phone_lib's Introduction

jenesiszw phone_lib

a classic wrapper for libphonenumber for PHP by https://github.com/giggsey

Get Started


Installtion

composer require jenesiszw/phone_lib:dev-master

Import vendor folder and PhoneLibrary class

<?php

use JenesisZw\PhoneLibrary;

require __DIR__ . '/vendor/autoload.php'';


Usage

$number = "0782000340";

$data =  $phone = (new PhoneLibrary($number, 'ZW'))
    ->parse()
    ->getIsValid()
    ->getNationalFormat()
    ->getInternationalFormat()
    ->getCarrierProvider()
    ->getPhoneDescription()
    ->getTimeZone()
    ->done();



function dd($data)
{
    echo "<code>";
    echo "<pre>";
    die(print_r($data, true));
    echo "</pre>";
    echo "</code>";
}


dd($data);


Response


Array
(
    [isValid] => true
    [nationalFormat] => 0782000340
    [internationalFormat] => +263 78 200 0340
    [carrierProvider] => Econet
    [country] => Zimbabwe
    [timeZone] => Africa/Harare
)


Available Methods

  1. getIsValid()
  • check if number is valid or not
  • returns bool
  1. getInternationalFormat()
  • get international format from the parsed number
  1. getNationalFormat()
  • get national format from the parsed number
  1. getE164Format()
  • get E164 format from the parsed number
  1. getCarrierProvider()
  • get carrier provider from the parsed number
  1. getTimeZone()
  • get time zone from the parsed number
  1. getPhoneDescription()
  • get country name from the parsed number
  1. parse()

  2. done()

  • returns details for the parsed phone number

Note: parse() and done() are the required methods, others are optional


License: MIT

Author: Nigel Jaure

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.