1 | <?php |
||
25 | class PhoneHelper extends Helper |
||
26 | { |
||
27 | use StringTemplateTrait; |
||
28 | |||
29 | /** |
||
30 | * Default config for this class |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $_defaultConfig = [ |
||
35 | 'templates' => [ |
||
36 | 'phone' => '<a href="{{url}}"{{attrs}}>{{content}}</a>' |
||
37 | ] |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * Prettify a phone number. |
||
42 | * |
||
43 | * This function can take either a 10 digit or 7 digit phone number and returns |
||
44 | * a more human readable version. |
||
45 | * |
||
46 | * @param int $number The phone number to be prettified |
||
47 | * @return string The prettified phone number |
||
48 | */ |
||
49 | public function format($number) |
||
62 | |||
63 | /** |
||
64 | * Creates an HTML telephone link. |
||
65 | * |
||
66 | * If the $url is empty, $title is used instead. |
||
67 | * |
||
68 | * ### Options |
||
69 | * |
||
70 | * - `escape` Set to false to disable escaping of title and attributes. |
||
71 | * - `escapeTitle` Set to false to disable escaping of title. Takes precedence |
||
72 | * over value of `escape`) |
||
73 | * |
||
74 | * @param string $title The content to be wrapped by `<a>` tags. |
||
75 | * @param string|null $url string The phone number to link to. |
||
76 | * @param array $options Array of options and HTML attributes. |
||
77 | * @return string An `<a />` element. |
||
78 | */ |
||
79 | public function link($title, $url = null, array $options = []) |
||
112 | |||
113 | /** |
||
114 | * Builds a telephone link from a passed in string |
||
115 | * |
||
116 | * The string passed in can be a number, formatted number, or tel url |
||
117 | * |
||
118 | * @param string $url The number or tel url to use in the link |
||
119 | * @return string rfc3966 formatted tel URL |
||
120 | */ |
||
121 | public function buildUrl($url) |
||
127 | } |
||
128 |