Fakoli Framework
PhoneNumberTypeRenderer Class Reference
+ Inheritance diagram for PhoneNumberTypeRenderer:
+ Collaboration diagram for PhoneNumberTypeRenderer:

Public Member Functions

 PhoneNumberTypeRenderer ()
 
- Public Member Functions inherited from AbstractTypeRenderer
 AbstractTypeRenderer ()
 

Static Public Member Functions

static format ($value, $template="")
 
static standard ($value)
 
static getValueParts ($value)
 
- Static Public Member Functions inherited from AbstractTypeRenderer
static format ($value, $template="")
 
static translationDateTemplate ($template, $includeTime=true)
 

Static Public Attributes

static $parts
 

Detailed Description

Definition at line 43 of file phone_number_type_renderer.inc.

Member Function Documentation

◆ format()

static PhoneNumberTypeRenderer::format (   $value,
  $template = "" 
)
static

Definition at line 57 of file phone_number_type_renderer.inc.

58  {
59  trace("PhoneNumberTypeRenderer function format value is $value", 4);
60  switch($template)
61  {
62 
63  case "standard":
64  return PhoneNumberTypeRenderer::standard($value);
65 
66  default:
67 
68  return PhoneNumberTypeRenderer::standard($value);
69  }
70 
71  return $value;
72  }
trace($msg, $lvl, $callStack=null)
Send output to the trace log.
Definition: functions.inc:959

◆ getValueParts()

static PhoneNumberTypeRenderer::getValueParts (   $value)
static

Definition at line 97 of file phone_number_type_renderer.inc.

98  {
99  //AJG - Remove any non-numeric formatting before slicing up
100  $value = preg_replace("/\\D/", "", $value);
101 
103 
104  $valueParts = array();
105 
106  $idx = 0;
107  foreach($parts as $part => $limit)
108  {
109  $valueParts[$part] = substr($value, $idx, $limit);
110  $idx += $limit;
111  }
112 
113  return $valueParts;
114  }

◆ PhoneNumberTypeRenderer()

PhoneNumberTypeRenderer::PhoneNumberTypeRenderer ( )

Definition at line 53 of file phone_number_type_renderer.inc.

54  {
55  }

◆ standard()

static PhoneNumberTypeRenderer::standard (   $value)
static

Definition at line 74 of file phone_number_type_renderer.inc.

75  {
76  trace("PhoneNumberTypeRenderer function standard value is $value", 4);
77  $valueParts = PhoneNumberTypeRenderer::getValueParts($value);
78 
79  $phone = implode($valueParts, "-");
80 
81  $area_code = $valueParts["area_code"];
82  $ext = $valueParts["extension"];
83  $phone = preg_replace("/^$area_code-/", "($area_code) ", $phone);
84  if($ext)
85  $phone = preg_replace("/-$ext$/", " ext $ext", $phone);
86  else
87  $phone = preg_replace("/-*$/", "", $phone);
88 
89  return $phone;
90  }
trace($msg, $lvl, $callStack=null)
Send output to the trace log.
Definition: functions.inc:959

Member Data Documentation

◆ $parts

PhoneNumberTypeRenderer::$parts
static
Initial value:
= array(
"area_code" => 3,
"exchange" => 3,
"" => 4,
"extension" => 6
)

Definition at line 45 of file phone_number_type_renderer.inc.


The documentation for this class was generated from the following file: