Completed
Push — master ( 0c53d4...debbec )
by David
09:08 queued 10s
created

Wordlift_Metabox_Field_Integer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 31
loc 31
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B html_input() 26 26 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
 * Metaxboxes: Integer Field.
4
 *
5
 * This file defines the Wordlift_Metabox_Field_Integer class which displays number field
6
 * in WordPress' entity posts pages.
7
 *
8
 * @since   3.18.0
9
 * @package Wordlift
10
 */
11
12
/**
13
 * The Wordlift_Metabox_Field_Integer class extends {@link WL_Metabox_Field} and provides
14
 * support for integer fields.
15
 *
16
 * @since   3.18.0
17
 * @package Wordlift
18
 */
19 View Code Duplication
class Wordlift_Metabox_Field_Integer extends WL_Metabox_Field {
0 ignored issues
show
Duplication introduced by
This class 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...
20
	/**
21
	 * @inheritdoc
22
	 */
23
	public function html_input( $text ) {
24
		@ob_start();
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
25
		?>
26
			<div class="wl-input-wrapper">
27
				<input
28
					type="number"
29
					id="<?php echo esc_attr( $this->meta_name ); ?>"
30
					class="<?php echo esc_attr( $this->meta_name ); ?>"
31
					value="<?php echo esc_attr( $text ) ?>"
32
					name="wl_metaboxes[<?php echo $this->meta_name; ?>][]"
33
					style="width:88%"
34
					min="0"
35
				/>
36
37
				<button class="button wl-remove-input wl-button" type="button">
38
					<?php esc_html_e( 'Remove', 'wordlift' ); ?>
39
				</button>
40
41
				<div class="wl-input-notice"></div>
42
			</div>
43
44
		<?php
45
		$html = ob_get_clean();
46
47
		return $html;
48
	}
49
}
50