Zend Framework: Zend_Filter_Phone Component Proposal
| Proposed Component Name | Zend_Filter_Phone |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Filter_Phone |
| Proposers | Thomas Weidner |
| Zend Liaison | TBD |
| Revision | 1.0 - 29 November 2009: Initial Draft. (wiki revision: 5) |
Table of Contents
1. Overview
Zend_Filter_Phone is a filter which converts numeric input to a phone number.
2. References
- Wikipedia - Telephone Numbers
- Wikipedia - E.123
- ITU-T
- Country Calling Code
- Wikipedia - North American Number Plan
- Zend_Validate_Phone
3. Component Requirements, Constraints, and Acceptance Criteria
- This component will convert numeric input to conform a specified phone number format.
- This component will support national and international formats.
- This component will support definition of propritary formats.
- This component will provide and use the same API as Zend_Validate_Phone
4. Dependencies on Other Framework Components
- Zend_Filter
- Zend_Filter_Exception
5. Theory of Operation
This components changes a given input so it conforms a given phone number format. You could give a number and convert it into an international format or a national format simply by changing one spezifier. You could also seperate the different number tokens of which a phone number consists.
6. Milestones / Tasks
- Milestone 1: [DONE] Proposal finished
- Milestone 2: Proposal accepted
- Milestone 3: Working implementation
- Milestone 4: Unit tests
- Milestone 5: Documentation
- Milestone 6: Moved to core
7. Class Index
- Zend_Filter_Phone
8. Use Cases
| UC-01 |
|---|
| UC-02 |
|---|
| UC-03 |
|---|
9. Class Skeletons
Labels:
None
12 Comments
comments.show.hideDec 01, 2009
Joó Ádám
Much needed!
Jul 20, 2010
Ahmed Shreef
I was coming now to add a new proposal for Zend_Locale_Phone and found this proposal while I was searching if someone already did submit one and I found this proposal. I don't know if what I was thinking about can be added to one of your Phone proposals or it can just be a new class [Zend_Locale_Phone]. so I need some guidance.
I was thinking about a class than can
- take a localized phone number and normalize it like converting +20 10 1234567 to 20101234567
the passed phone number could be of any kind of format
- take localized number and reformat it to a any chosen format
- take a phone number and try to get its country like taking +20 10 1234567 and returning EG.
I did already did work on this one and this was the start of my idea about the proposal
- return country code [ 1, 20 ] by locale [US, EG ..]
- return locale(s) by country code (this can be kind of tricky as countries like US & CA use the same country code [1] ).
I don't know if these can make a new class or not, but anyway I will be glad to help with these classes under your lead. I'm working now in a telecommunication company on a project that all about phone numbers [mainly SMS], so this is what I do daily anyway.
thanks
Jul 21, 2010
Andreas Heigl
Interesting idea.
The trouble with the same country code probably could be circumvented when taking the area code into account.
This I think would also be necessary when estimating locales for countries that use more than one locale as switzerland for instance where you would return fr_CH, de_CH, it_CH or rm_CH according to the area-code.
Not sure whether that would work though.
Jul 21, 2010
Ahmed Shreef
Great, I don't know if there is an organization that can provide us with accurate and updated area codes for all countries, but anyway we still have the list provided by Wikipedia.
about countries with many locales, we can just use the second part [country/region] as the the first part is the [language] . so for Switzerland we will return [CH] without the language.
Jul 24, 2010
Thomas Weidner
Area codes within a country are always declared by the country itself.
There is no international or other organisation which can provide this information.
You can of course get a list from a provider (I have such data and access) but this information can never be complete as it's information which changes every month. Many countries don't even have an organisation where you can get such informations.
Regarding locale and country: this is no problem in reallity.
Jul 24, 2010
Thomas Weidner
Zend_Locale_Phone is already in progress. It is an extension on the provided data like the plural rules which are also locale data. There is no need to make an extra proposal for this additional data because Zend_Locale_Phone will not change numbers.
Therefor this proposal has been added. But as this proposal has not beed accepted for now, I am also not working on it.
In sum there are 3 components which are needed to work on phone numbers.
Zend_Locale which provides that needed number informations. No proposal needed.
Zend_Validator_Phone which validates phone numbers. Already accepted.
Zend_Filter_Phone which normalizes, localizes and changes phone numbers. Not accepted for now.
When the last component has been accepted I am able to start my work. Until then you may have to wait.
The information you described is a combination of Locale and Filter.
Jul 24, 2010
Ahmed Shreef
great work, this is all what I wanted to know. I will wait till the final proposal is accepted and will be glad to help with testing and reporting issues.
regards
Jul 28, 2010
Dolf Schimmel (Freeaqingme)
Can it also be used 'in reverse'? Meaning that when i input 1 (257) 12345 - 67 i get as result: 2571234567?
Jul 30, 2010
Thomas Weidner
Not in all cases but normally yes.
It would for example not be possible to revert your result to 1 (xxx) yyy again without knowing the country. Therefor the locale (region) is used in the above examples.
Jul 28, 2010
Shaun Farrell
I know in the US there are many was to output a phone #. Is there a way to set custom format like ###
####### or (###) ###-#### or ###.###.#### etc..What about phone extensions?
Jul 30, 2010
Thomas Weidner
As you can see in the above "usecase 3" extensions are supported.
Aug 03, 2010
Shaun Farrell
The CR Team advises that this proposal be approved.