Completed
Pull Request — master (#114)
by
unknown
02:50
created

FrmFieldPhone   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 21.62 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 8
loc 37
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A field_settings_for_type() 8 8 1
A html5_input_type() 0 5 2
A sanitize_value() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * @since 3.0
5
 */
6
class FrmFieldPhone extends FrmFieldType {
7
8
	/**
9
	 * @var string
10
	 * @since 3.0
11
	 */
12
	protected $type = 'phone';
13
	protected $display_type = 'text';
14
15
	/**
16
	 * @var bool
17
	 * @since 3.0
18
	 */
19
	protected $holds_email_values = true;
20
21 View Code Duplication
	protected function field_settings_for_type() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
		return array(
23
			'size'           => true,
24
			'clear_on_focus' => true,
25
			'invalid'        => true,
26
			'format'         => true,
27
		);
28
	}
29
30
	protected function html5_input_type() {
31
		$frm_settings = FrmAppHelper::get_settings();
32
33
		return $frm_settings->use_html ? 'tel' : 'text';
34
	}
35
36
	/**
37
	 * @since 4.0
38
	 */
39
	public function sanitize_value( &$value ) {
40
		FrmAppHelper::sanitize_value( 'sanitize_text_field', $value );
41
	}
42
}
43