potatopowered/phone-helper

A CakePHP 3.x telephone number formatting plugin.

Installs: 12 480

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 3

Forks: 1

Open Issues: 0

Type:cakephp-plugin

v2.0.0 2016-09-30 04:45 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:56:56 UTC


README

Software License Travis Codecov Scrutinizer Packagist

A phone number formatting helper for CakePHP 3.x

Description

The phone number helper is designed to help format phone numbers of all types into tel links or just a prettified format. Please send a pull request if you do not see your phone number format included.

Installation

composer require potatopowered/phone-helper

Add the helper to the public helpers variable of the controller you need it on or in the AppController to have it accessible in all controllers.

public $helpers = [
    'Phone' => [
        'className' => 'PhoneHelper.Phone'
    ]
];

Usage

To use the phone number formatter you must have the helper loaded in your controller. Once loaded in the controller as shown above you can call the number helper's format($number) function.

// (123) 456-789
$this->Phone->format('1234567890');

// 456-7890
$this->Phone->format('4567890');

You can also add telephone links in RFC3966 format using the 'link' method

// <a href="tel:+1234567890">123-456-7890</a>
$this->Phone->link('123-456-7890');

// <a href="tel:+1234567890">Call Us</a>
$this->Phone->link(h('Call Us'), '1234567890');