Handle phone numbers.
Simplify working with phone numbers.
Rotary will support numbers that look like the standard number format used in the United State of America, i.e.
nnn nnn-nnnn. These can also be prepended with an international country code up to 5 digit long, i.e.
nn nnn nnn-nnnn. Numbers that deviate from this pattern cannot be reliably interpreted.
Although all the internal behaviors are easily accessible (with the exception of the
Number class, all methods are available as static methods), in general, you'll just be using these methods from the
prettywill result in
simplewill result in
hrefwill result in
normalizedwill result in
You can call them like this:
use AlwaysBlank\Rotary\Render; echo Render::pretty('1234567890'); // (123) 456-7890 echo Render::pretty('123 456 7890'); // (123) 456-7890 echo Render::pretty('[123) 456/7890'); // (123) 456-7890
You can also instantiate a
Rotary object, which has methods for the different format types:
use AlwaysBlank\Rotary\Rotary; $Rotary = new Rotary('123456789'); echo $Rotary->pretty(); // (123) 456-7890
This can be useful if you want access to several formats on one number.
You can put any non-digit characters you like in your argument and Rotary will simply ignore them--it cares only for digits.
2dfsad__34-5)(6=78are identical so far as it's concerned.
Note: Rotary will try to interpret strange arguments, but it has limits, so please try to pass it numbers that make sense. 🙏