The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Number::MuPhone::Parser

VERSION

version 0,01

DESCRIPTION

Base phone number parser class. Contains sane defaults.

This document covers how you might want to tweak Parser methods on a per country basis. For further documentation, please see the Number::MuPhone POD.

If you do find a need, please contact me so I can merge useful changes in as needed.

For each Number::MuPhone::Parser::COUNTRY.pm module, you must set values for the attributes country, country_code, country_name, _national_dial_prefix and _international_dial_prefix. eg:

    has '+country'                    => ( default => 'UK'             );
    has '+country_code'               => ( default => '44'             );
    has '+country_name'               => ( default => 'United Kingdom' );
    has '+_national_dial_prefix'      => ( default => '0'              );
    has '+_international_dial_prefix' => ( default => '00'             );

These are already set for known countries.

COMMONLY OVERLOADED METHODS

Pretty much anything *may* benefit from overloading on a per country basis, but these are the most common methods that are need to be overloaded.

_format_number()

Different countries have different ways of displaying phone numbers.

The method _format_number is used to take the raw number (minus any extension) and format it a way that is normal for that country. The US's formatter is simple; the UK's, not so much. It doesn't just do that though. It:

* confirms the number is valid; * formats the number for common display; * sets an error() if there's a problem; and * sets the value in the _formatted_number accessor.

On completion of validation, it returns the formatted number if valid, or the original number if an error was encountered.

There's a generic default, but it should be overloaded in each country's Parser. This is an ongoing project to replace.

_extension_text

Text to display after the number plus a space, but before the extension.

This defaults to the english 'ext ' but can be overloaded in individual countries as needed.

display_from( $num | $num_obj | country )

This works out of the box for 90% of countries, but there are a few places where this may need overwriting - eg, dialing French territories from France.

dial_from( $num | $num_obj | country )

This works out of the box for 90% of countries, but there are a few places where this may need overwriting - eg, dialing French territories from France.

_parse_number_and_extension

Basically split the entered number on a string that marks an extension.

Defaults to English.

Can amend this rule as needed in country classes

AUTHOR

Clive Holloway <clive.holloway@gmail.com>

Copyright (c) 2017 Clive Holloway