Completed
Branch BUG-11107-submit-button-text (9a9413)
by
unknown
31:37 queued 21:44
created

EE_Button_Input   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 22.5 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 9
loc 40
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 2
A set_button_content() 0 4 1
A button_content() 0 4 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 if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
/**
3
 * EE_Button_Input
4
 * Similar to EE_Submit_Input, but renders a button element, and its text being displayed
5
 * can differ from the value, and it can contain HTML.
6
 * @package			Event Espresso
7
 * @subpackage
8
 * @author				Mike Nelson
9
 *
10
 */
11
class EE_Button_Input extends EE_Form_Input_Base{
12
13
    /**
14
     * @var string of HTML to put between the button tags
15
     */
16
    protected $_button_content;
17
	/**
18
	 * @param array $options
19
	 */
20 View Code Duplication
	public function __construct($options = array()){
21
	    if( empty($options['button_content'])) {
22
	        $options['button_content'] = esc_html__('Button', 'event_espresso');
23
        }
24
		$this->_set_display_strategy(new EE_Button_Display_Strategy());
25
		$this->_set_normalization_strategy(new EE_Text_Normalization());
26
		$this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy() );
27
		parent::__construct($options);
28
	}
29
30
31
32
    /**
33
     * Sets the button content
34
     * @see EE_Button_Input::$_button_content
35
     * @param string $new_content
36
     */
37
	public function set_button_content($new_content)
38
    {
39
	    $this->_button_content = $new_content;
40
    }
41
    
42
    /**
43
     * Gets the button content
44
     * @return string
45
     */
46
	public function button_content()
47
    {
48
        return $this->_button_content;
49
    }
50
}
51