Passed
Push — release-3.0.0 ( e8971e...d75c10 )
by Daniel
04:23
created

telephone::get_field_value()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\services\form\field;
11
12
class telephone extends number
13
{
14
	/**
15
	 * @inheritdoc
16
	 */
17
	public function get_name()
18
	{
19
		return 'telephone';
20
	}
21
22
	/**
23
	 * @inheritdoc
24
	 */
25
	public function get_default_props()
26
	{
27
		return array(
28
			'min'	=> 0,
29
			'max'	=> 200,
30
			'size'	=> 10,
31
		);
32
	}
33
34
	/**
35
	 * @inheritdoc
36
	 */
37
	public function display_field(array $data, array $topic_data, $view_mode)
38
	{
39
		return $data['field_value'] ? '<a href="tel:' . $data['field_value'] . '">' . preg_replace("/^1?(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", $data['field_value']) . '</a>' : '';
40
	}
41
}
42