Completed
Branch FET/extract-activation-detecti... (285969)
by
unknown
02:37 queued 19s
created
libraries/form_sections/payment_methods/EE_Payment_Method_Form.form.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function _construct_finalize($parent_form_section, $name)
106 106
     {
107
-        if (! $this->_payment_method_type instanceof EE_PMT_Base) {
107
+        if ( ! $this->_payment_method_type instanceof EE_PMT_Base) {
108 108
             throw new EE_Error(sprintf(esc_html__(
109 109
                 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize',
110 110
                 'event_espresso'
111 111
             )));
112 112
         }
113 113
         // set the name of this form based on the payment method type
114
-        if (! $this->_name && ! $name) {
114
+        if ( ! $this->_name && ! $name) {
115 115
             $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))
116 116
                     . "_Settings_Form";
117 117
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function set_payment_method_type($payment_method_type)
128 128
     {
129
-        if (! $payment_method_type instanceof EE_PMT_Base) {
129
+        if ( ! $payment_method_type instanceof EE_PMT_Base) {
130 130
             throw new EE_Error(sprintf(esc_html__(
131 131
                 "Payment Method forms MUST set a payment method type by using _set_payment_method_type",
132 132
                 "event_espresso"
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
         parent::populate_model_obj($model_obj);
167 167
         $extra_meta = $model_obj->all_extra_meta_array();
168 168
         foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) {
169
-            if (isset($extra_meta[ $input_name ])) {
170
-                $extra_meta_input->set_default($extra_meta[ $input_name ]);
169
+            if (isset($extra_meta[$input_name])) {
170
+                $extra_meta_input->set_default($extra_meta[$input_name]);
171 171
             }
172 172
         }
173 173
     }
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
      */
182 182
     protected function _set_default_name_if_empty()
183 183
     {
184
-        if (! $this->_name) {
185
-            $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form";
184
+        if ( ! $this->_name) {
185
+            $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form";
186 186
             $this->_name = $default_name;
187 187
         }
188 188
     }
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -6,195 +6,195 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Payment_Method_Form extends EE_Model_Form_Section
8 8
 {
9
-    /**
10
-     * All the subsection inputs that correspond ot extra meta rows
11
-     * for this payment method
12
-     *
13
-     * @var EE_Form_Input_Base[]
14
-     */
15
-    protected $_extra_meta_inputs = array();
16
-
17
-    /**
18
-     * Because payment method form might DELAY part of construction, we want to remember
19
-     * what options were passed in
20
-     *
21
-     * @var array
22
-     */
23
-    protected $_options_array = array();
24
-
25
-    /**
26
-     * The payment method type for this form
27
-     *
28
-     * @var EE_PMT_Base
29
-     */
30
-    protected $_payment_method_type;
31
-
32
-
33
-
34
-    /**
35
-     * @param array      $options_array       {
36
-     * @type string      $extra_meta_inputs   should be EE_Form_Section_Validatable[] which
37
-     *                                        will be _subsections and will be saved as extra meta on the payment
38
-     *                                        method object;
39
-     * @type EE_PMT_Base $payment_method_type the payment method type this form is for
40
-     * @see EE_Model_Form_Section::__construct() for more
41
-     *                                        }
42
-     */
43
-    public function __construct($options_array = array())
44
-    {
45
-        $this->_model = EEM_Payment_Method::instance();
46
-        $this->_options_array = $options_array;
47
-        if (isset($options_array['payment_method_type'])) {
48
-            $this->_payment_method_type = $options_array['payment_method_type'];
49
-        }
50
-        $options_array = $this->_options_array;
51
-        if (isset($options_array['extra_meta_inputs'])) {
52
-            $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']);
53
-        }
54
-        if ($this->_extra_meta_inputs) {
55
-            $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs);
56
-        }
57
-        $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input(
58
-            array('html_label_text' => esc_html__('Button URL', 'event_espresso'))
59
-        );
60
-        $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input(
61
-            EEM_Payment_Method::instance()->scopes(),
62
-            array(
63
-                'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename()
64
-                                     . EEH_Template::get_help_tab_link('payment_methods_overview'),
65
-            )
66
-        );
67
-        // setup the currency options
68
-        $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input(
69
-            EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type),
70
-            array(
71
-                'html_label_text' => esc_html__('Currencies Supported', 'event_espresso'),
72
-                'required'        => true,
73
-            )
74
-        );
75
-        $this->_subsections['PMD_order'] = new EE_Text_Input(array(
76
-            'html_label_text'        => esc_html__('Order', 'event_espresso'),
77
-            'html_help_text'         => esc_html__('Lowest numbers will be shown first', 'event_espresso'),
78
-            'normalization_strategy' => new EE_Int_Normalization(),
79
-            'validation_strategies'  => array(
80
-                new EE_Int_Validation_Strategy(),
81
-            ),
82
-            'default'                => 0,
83
-        ));
84
-        $this->_layout_strategy = new EE_Admin_Two_Column_Layout();
85
-        parent::__construct($options_array);
86
-        $debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null;
87
-        if ($debug_mode instanceof EE_Form_Input_Base) {
88
-            $debug_mode->set_html_help_text(esc_html__(
89
-                'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.',
90
-                'event_espresso'
91
-            ));
92
-        }
93
-    }
94
-
95
-
96
-
97
-    /**
98
-     * Finishes construction given the parent form section and this form section's name
99
-     *
100
-     * @param EE_Form_Section_Proper $parent_form_section
101
-     * @param string                 $name
102
-     * @throws EE_Error
103
-     */
104
-    public function _construct_finalize($parent_form_section, $name)
105
-    {
106
-        if (! $this->_payment_method_type instanceof EE_PMT_Base) {
107
-            throw new EE_Error(sprintf(esc_html__(
108
-                'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize',
109
-                'event_espresso'
110
-            )));
111
-        }
112
-        // set the name of this form based on the payment method type
113
-        if (! $this->_name && ! $name) {
114
-            $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))
115
-                    . "_Settings_Form";
116
-        }
117
-        parent::_construct_finalize($parent_form_section, $name);
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @param $payment_method_type
124
-     * @throws EE_Error
125
-     */
126
-    public function set_payment_method_type($payment_method_type)
127
-    {
128
-        if (! $payment_method_type instanceof EE_PMT_Base) {
129
-            throw new EE_Error(sprintf(esc_html__(
130
-                "Payment Method forms MUST set a payment method type by using _set_payment_method_type",
131
-                "event_espresso"
132
-            )));
133
-        }
134
-        $this->_payment_method_type = $payment_method_type;
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     * extends the model form section's save method to also save the extra meta field values
141
-     *
142
-     * @return int ID of the payment method inserted, or true on update
143
-     */
144
-    public function save()
145
-    {
146
-        $parent_save_val = parent::save();
147
-        if ($this->_model_object && $this->_model_object->ID()) {
148
-            foreach ($this->_extra_meta_inputs as $input_name => $input) {
149
-                $this->_model_object->update_extra_meta($input_name, $input->normalized_value());
150
-            }
151
-        }
152
-        return $parent_save_val;
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     * Overrides parent's populate_model_obj to also populate the extra meta fields
159
-     *
160
-     * @param EE_Base_Class $model_obj
161
-     */
162
-    public function populate_model_obj($model_obj)
163
-    {
164
-        $model_obj = $this->_model->ensure_is_obj($model_obj);
165
-        parent::populate_model_obj($model_obj);
166
-        $extra_meta = $model_obj->all_extra_meta_array();
167
-        foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) {
168
-            if (isset($extra_meta[ $input_name ])) {
169
-                $extra_meta_input->set_default($extra_meta[ $input_name ]);
170
-            }
171
-        }
172
-    }
173
-
174
-
175
-
176
-    /**
177
-     * gets the default name of this form section if none is specified
178
-     *
179
-     * @return string
180
-     */
181
-    protected function _set_default_name_if_empty()
182
-    {
183
-        if (! $this->_name) {
184
-            $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form";
185
-            $this->_name = $default_name;
186
-        }
187
-    }
188
-
189
-
190
-
191
-    /**
192
-     * Gets all the extra meta inputs in this form
193
-     *
194
-     * @return EE_Form_Input_Base[]
195
-     */
196
-    public function extra_meta_inputs()
197
-    {
198
-        return $this->_extra_meta_inputs;
199
-    }
9
+	/**
10
+	 * All the subsection inputs that correspond ot extra meta rows
11
+	 * for this payment method
12
+	 *
13
+	 * @var EE_Form_Input_Base[]
14
+	 */
15
+	protected $_extra_meta_inputs = array();
16
+
17
+	/**
18
+	 * Because payment method form might DELAY part of construction, we want to remember
19
+	 * what options were passed in
20
+	 *
21
+	 * @var array
22
+	 */
23
+	protected $_options_array = array();
24
+
25
+	/**
26
+	 * The payment method type for this form
27
+	 *
28
+	 * @var EE_PMT_Base
29
+	 */
30
+	protected $_payment_method_type;
31
+
32
+
33
+
34
+	/**
35
+	 * @param array      $options_array       {
36
+	 * @type string      $extra_meta_inputs   should be EE_Form_Section_Validatable[] which
37
+	 *                                        will be _subsections and will be saved as extra meta on the payment
38
+	 *                                        method object;
39
+	 * @type EE_PMT_Base $payment_method_type the payment method type this form is for
40
+	 * @see EE_Model_Form_Section::__construct() for more
41
+	 *                                        }
42
+	 */
43
+	public function __construct($options_array = array())
44
+	{
45
+		$this->_model = EEM_Payment_Method::instance();
46
+		$this->_options_array = $options_array;
47
+		if (isset($options_array['payment_method_type'])) {
48
+			$this->_payment_method_type = $options_array['payment_method_type'];
49
+		}
50
+		$options_array = $this->_options_array;
51
+		if (isset($options_array['extra_meta_inputs'])) {
52
+			$this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']);
53
+		}
54
+		if ($this->_extra_meta_inputs) {
55
+			$this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs);
56
+		}
57
+		$this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input(
58
+			array('html_label_text' => esc_html__('Button URL', 'event_espresso'))
59
+		);
60
+		$this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input(
61
+			EEM_Payment_Method::instance()->scopes(),
62
+			array(
63
+				'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename()
64
+									 . EEH_Template::get_help_tab_link('payment_methods_overview'),
65
+			)
66
+		);
67
+		// setup the currency options
68
+		$this->_subsections['Currency'] = new EE_Select_Multi_Model_Input(
69
+			EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type),
70
+			array(
71
+				'html_label_text' => esc_html__('Currencies Supported', 'event_espresso'),
72
+				'required'        => true,
73
+			)
74
+		);
75
+		$this->_subsections['PMD_order'] = new EE_Text_Input(array(
76
+			'html_label_text'        => esc_html__('Order', 'event_espresso'),
77
+			'html_help_text'         => esc_html__('Lowest numbers will be shown first', 'event_espresso'),
78
+			'normalization_strategy' => new EE_Int_Normalization(),
79
+			'validation_strategies'  => array(
80
+				new EE_Int_Validation_Strategy(),
81
+			),
82
+			'default'                => 0,
83
+		));
84
+		$this->_layout_strategy = new EE_Admin_Two_Column_Layout();
85
+		parent::__construct($options_array);
86
+		$debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null;
87
+		if ($debug_mode instanceof EE_Form_Input_Base) {
88
+			$debug_mode->set_html_help_text(esc_html__(
89
+				'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.',
90
+				'event_espresso'
91
+			));
92
+		}
93
+	}
94
+
95
+
96
+
97
+	/**
98
+	 * Finishes construction given the parent form section and this form section's name
99
+	 *
100
+	 * @param EE_Form_Section_Proper $parent_form_section
101
+	 * @param string                 $name
102
+	 * @throws EE_Error
103
+	 */
104
+	public function _construct_finalize($parent_form_section, $name)
105
+	{
106
+		if (! $this->_payment_method_type instanceof EE_PMT_Base) {
107
+			throw new EE_Error(sprintf(esc_html__(
108
+				'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize',
109
+				'event_espresso'
110
+			)));
111
+		}
112
+		// set the name of this form based on the payment method type
113
+		if (! $this->_name && ! $name) {
114
+			$name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))
115
+					. "_Settings_Form";
116
+		}
117
+		parent::_construct_finalize($parent_form_section, $name);
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @param $payment_method_type
124
+	 * @throws EE_Error
125
+	 */
126
+	public function set_payment_method_type($payment_method_type)
127
+	{
128
+		if (! $payment_method_type instanceof EE_PMT_Base) {
129
+			throw new EE_Error(sprintf(esc_html__(
130
+				"Payment Method forms MUST set a payment method type by using _set_payment_method_type",
131
+				"event_espresso"
132
+			)));
133
+		}
134
+		$this->_payment_method_type = $payment_method_type;
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 * extends the model form section's save method to also save the extra meta field values
141
+	 *
142
+	 * @return int ID of the payment method inserted, or true on update
143
+	 */
144
+	public function save()
145
+	{
146
+		$parent_save_val = parent::save();
147
+		if ($this->_model_object && $this->_model_object->ID()) {
148
+			foreach ($this->_extra_meta_inputs as $input_name => $input) {
149
+				$this->_model_object->update_extra_meta($input_name, $input->normalized_value());
150
+			}
151
+		}
152
+		return $parent_save_val;
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 * Overrides parent's populate_model_obj to also populate the extra meta fields
159
+	 *
160
+	 * @param EE_Base_Class $model_obj
161
+	 */
162
+	public function populate_model_obj($model_obj)
163
+	{
164
+		$model_obj = $this->_model->ensure_is_obj($model_obj);
165
+		parent::populate_model_obj($model_obj);
166
+		$extra_meta = $model_obj->all_extra_meta_array();
167
+		foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) {
168
+			if (isset($extra_meta[ $input_name ])) {
169
+				$extra_meta_input->set_default($extra_meta[ $input_name ]);
170
+			}
171
+		}
172
+	}
173
+
174
+
175
+
176
+	/**
177
+	 * gets the default name of this form section if none is specified
178
+	 *
179
+	 * @return string
180
+	 */
181
+	protected function _set_default_name_if_empty()
182
+	{
183
+		if (! $this->_name) {
184
+			$default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form";
185
+			$this->_name = $default_name;
186
+		}
187
+	}
188
+
189
+
190
+
191
+	/**
192
+	 * Gets all the extra meta inputs in this form
193
+	 *
194
+	 * @return EE_Form_Input_Base[]
195
+	 */
196
+	public function extra_meta_inputs()
197
+	{
198
+		return $this->_extra_meta_inputs;
199
+	}
200 200
 }
Please login to merge, or discard this patch.
strategies/display/EE_Select_Multiple_Display_Strategy.strategy.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
     public function display()
21 21
     {
22 22
 
23
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
23
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
24 24
             throw new EE_Error(sprintf(esc_html__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso")));
25 25
         }
26 26
 
27 27
         $html = EEH_HTML::nl(0, 'select');
28 28
         $html .= '<select multiple';
29
-        $html .= ' id="' . $this->_input->html_id() . '"';
30
-        $html .= ' name="' . $this->_input->html_name() . '[]"';
31
-        $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
32
-        $html .= ' class="' . $class . '"';
29
+        $html .= ' id="'.$this->_input->html_id().'"';
30
+        $html .= ' name="'.$this->_input->html_name().'[]"';
31
+        $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class();
32
+        $html .= ' class="'.$class.'"';
33 33
         // add html5 required
34 34
         $html .= $this->_input->required() ? ' required' : '';
35
-        $html .= ' style="' . $this->_input->html_style() . '"';
36
-        $html .= ' ' . $this->_input->other_html_attributes();
35
+        $html .= ' style="'.$this->_input->html_style().'"';
36
+        $html .= ' '.$this->_input->other_html_attributes();
37 37
         $html .= '>';
38 38
 
39 39
         EEH_HTML::indent(1, 'select');
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             $html .= $this->_display_options($this->_input->options());
44 44
         }
45 45
 
46
-        $html .= EEH_HTML::nl(-1, 'select') . "</select>";
46
+        $html .= EEH_HTML::nl(-1, 'select')."</select>";
47 47
         return $html;
48 48
     }
49 49
 
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -11,54 +11,54 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Select_Multiple_Display_Strategy extends EE_Select_Display_Strategy
13 13
 {
14
-    /**
15
-     *
16
-     * @throws EE_Error
17
-     * @return string of html to display the field
18
-     */
19
-    public function display()
20
-    {
14
+	/**
15
+	 *
16
+	 * @throws EE_Error
17
+	 * @return string of html to display the field
18
+	 */
19
+	public function display()
20
+	{
21 21
 
22
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
23
-            throw new EE_Error(sprintf(esc_html__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso")));
24
-        }
22
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
23
+			throw new EE_Error(sprintf(esc_html__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso")));
24
+		}
25 25
 
26
-        $html = EEH_HTML::nl(0, 'select');
27
-        $html .= '<select multiple';
28
-        $html .= ' id="' . $this->_input->html_id() . '"';
29
-        $html .= ' name="' . $this->_input->html_name() . '[]"';
30
-        $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
31
-        $html .= ' class="' . $class . '"';
32
-        // add html5 required
33
-        $html .= $this->_input->required() ? ' required' : '';
34
-        $html .= ' style="' . $this->_input->html_style() . '"';
35
-        $html .= ' ' . $this->_input->other_html_attributes();
36
-        $html .= '>';
26
+		$html = EEH_HTML::nl(0, 'select');
27
+		$html .= '<select multiple';
28
+		$html .= ' id="' . $this->_input->html_id() . '"';
29
+		$html .= ' name="' . $this->_input->html_name() . '[]"';
30
+		$class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
31
+		$html .= ' class="' . $class . '"';
32
+		// add html5 required
33
+		$html .= $this->_input->required() ? ' required' : '';
34
+		$html .= ' style="' . $this->_input->html_style() . '"';
35
+		$html .= ' ' . $this->_input->other_html_attributes();
36
+		$html .= '>';
37 37
 
38
-        EEH_HTML::indent(1, 'select');
39
-        if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
40
-            throw new EE_Error(sprintf(esc_html__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso")));
41
-        } else {
42
-            $html .= $this->_display_options($this->_input->options());
43
-        }
38
+		EEH_HTML::indent(1, 'select');
39
+		if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
40
+			throw new EE_Error(sprintf(esc_html__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso")));
41
+		} else {
42
+			$html .= $this->_display_options($this->_input->options());
43
+		}
44 44
 
45
-        $html .= EEH_HTML::nl(-1, 'select') . "</select>";
46
-        return $html;
47
-    }
45
+		$html .= EEH_HTML::nl(-1, 'select') . "</select>";
46
+		return $html;
47
+	}
48 48
 
49 49
 
50 50
 
51
-    /**
52
-     * Checks if that $value is one of the selected ones
53
-     * @param string|int $value unnormalized value option (string)
54
-     * @return boolean
55
-     */
56
-    protected function _check_if_option_selected($value)
57
-    {
58
-        $selected_options = $this->_input->raw_value();
59
-        if (empty($selected_options)) {
60
-            return false;
61
-        }
62
-        return in_array($value, $selected_options) ? true : false;
63
-    }
51
+	/**
52
+	 * Checks if that $value is one of the selected ones
53
+	 * @param string|int $value unnormalized value option (string)
54
+	 * @return boolean
55
+	 */
56
+	protected function _check_if_option_selected($value)
57
+	{
58
+		$selected_options = $this->_input->raw_value();
59
+		if (empty($selected_options)) {
60
+			return false;
61
+		}
62
+		return in_array($value, $selected_options) ? true : false;
63
+	}
64 64
 }
Please login to merge, or discard this patch.
strategies/display/EE_Compound_Input_Display_Strategy.strategy.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function get_sub_input_id($option_value, $add_pound_sign = false)
27 27
     {
28
-        return $this->_append_chars($this->_input->html_id($add_pound_sign), '-') . sanitize_key($option_value);
28
+        return $this->_append_chars($this->_input->html_id($add_pound_sign), '-').sanitize_key($option_value);
29 29
     }
30 30
 
31 31
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function get_input()
59 59
     {
60
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
60
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
61 61
             throw new EE_Error(
62 62
                 sprintf(
63 63
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -15,57 +15,57 @@
 block discarded – undo
15 15
  */
16 16
 abstract class EE_Compound_Input_Display_Strategy extends EE_Display_Strategy_Base
17 17
 {
18
-    /**
19
-     * Gets the html ID for the sub-input for the specified option html value (not display text)
20
-     *
21
-     * @param string $option_value
22
-     * @param bool   $add_pound_sign
23
-     * @return string
24
-     */
25
-    public function get_sub_input_id($option_value, $add_pound_sign = false)
26
-    {
27
-        return $this->_append_chars($this->_input->html_id($add_pound_sign), '-') . sanitize_key($option_value);
28
-    }
18
+	/**
19
+	 * Gets the html ID for the sub-input for the specified option html value (not display text)
20
+	 *
21
+	 * @param string $option_value
22
+	 * @param bool   $add_pound_sign
23
+	 * @return string
24
+	 */
25
+	public function get_sub_input_id($option_value, $add_pound_sign = false)
26
+	{
27
+		return $this->_append_chars($this->_input->html_id($add_pound_sign), '-') . sanitize_key($option_value);
28
+	}
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * Gets the HTML IDs of all the inputs
34
-     *
35
-     * @param boolean $add_pound_sign
36
-     * @return array
37
-     * @throws \EE_Error
38
-     */
39
-    public function get_html_input_ids($add_pound_sign = false)
40
-    {
41
-        $html_input_ids = array();
42
-        foreach ($this->get_input()->options() as $value => $display) {
43
-            $html_input_ids[] = $this->get_sub_input_id($value, $add_pound_sign);
44
-        }
45
-        return $html_input_ids;
46
-    }
32
+	/**
33
+	 * Gets the HTML IDs of all the inputs
34
+	 *
35
+	 * @param boolean $add_pound_sign
36
+	 * @return array
37
+	 * @throws \EE_Error
38
+	 */
39
+	public function get_html_input_ids($add_pound_sign = false)
40
+	{
41
+		$html_input_ids = array();
42
+		foreach ($this->get_input()->options() as $value => $display) {
43
+			$html_input_ids[] = $this->get_sub_input_id($value, $add_pound_sign);
44
+		}
45
+		return $html_input_ids;
46
+	}
47 47
 
48 48
 
49 49
 
50
-    /**
51
-     * Overrides parent to make sure this display strategy is only used with the
52
-     * appropriate input type
53
-     *
54
-     * @return \EE_Form_Input_With_Options_Base
55
-     * @throws \EE_Error
56
-     */
57
-    public function get_input()
58
-    {
59
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
60
-            throw new EE_Error(
61
-                sprintf(
62
-                    esc_html__(
63
-                        'Can not use a Compound Input Display Strategy (eg checkbox or radio) with an input that doesn\'t have options',
64
-                        'event_espresso'
65
-                    )
66
-                )
67
-            );
68
-        }
69
-        return parent::get_input();
70
-    }
50
+	/**
51
+	 * Overrides parent to make sure this display strategy is only used with the
52
+	 * appropriate input type
53
+	 *
54
+	 * @return \EE_Form_Input_With_Options_Base
55
+	 * @throws \EE_Error
56
+	 */
57
+	public function get_input()
58
+	{
59
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
60
+			throw new EE_Error(
61
+				sprintf(
62
+					esc_html__(
63
+						'Can not use a Compound Input Display Strategy (eg checkbox or radio) with an input that doesn\'t have options',
64
+						'event_espresso'
65
+					)
66
+				)
67
+			);
68
+		}
69
+		return parent::get_input();
70
+	}
71 71
 }
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_URL_Validation_Strategy.strategy.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
         $check_file_exists = false,
40 40
         URLValidator $url_validator = null
41 41
     ) {
42
-        if (! $url_validator instanceof URLValidator) {
42
+        if ( ! $url_validator instanceof URLValidator) {
43 43
             $url_validator = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\validators\URLValidator');
44 44
         }
45 45
         $this->url_validator = $url_validator;
46
-        if (! $validation_error_message) {
46
+        if ( ! $validation_error_message) {
47 47
             $validation_error_message = esc_html__("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
48 48
         }
49 49
         $this->check_file_exists = $check_file_exists;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     public function validate($normalized_value)
63 63
     {
64 64
         if ($normalized_value) {
65
-            if (! $this->url_validator->isValid($normalized_value)) {
65
+            if ( ! $this->url_validator->isValid($normalized_value)) {
66 66
                 throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
67 67
             } elseif (apply_filters('FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', $this->check_file_exists, $this->_input)) {
68 68
                 if (
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $normalized_value,
71 71
                         array(
72 72
                             'sslverify' => false,
73
-                            'limit_response_size' => 4095,// we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
73
+                            'limit_response_size' => 4095, // we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
74 74
                         )
75 75
                     )
76 76
                 ) {
@@ -87,6 +87,6 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function get_jquery_validation_rule_array()
89 89
     {
90
-        return array( 'validUrl' => true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
90
+        return array('validUrl' => true, 'messages' => array('validUrl' => $this->get_validation_error_message()));
91 91
     }
92 92
 }
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -15,77 +15,77 @@
 block discarded – undo
15 15
  */
16 16
 class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base
17 17
 {
18
-    /**
19
-     * @var @boolean whether we should check if the file exists or not
20
-     */
21
-    protected $check_file_exists;
18
+	/**
19
+	 * @var @boolean whether we should check if the file exists or not
20
+	 */
21
+	protected $check_file_exists;
22 22
 
23
-    /**
24
-     * @var URLValidator
25
-     */
26
-    protected $url_validator;
23
+	/**
24
+	 * @var URLValidator
25
+	 */
26
+	protected $url_validator;
27 27
 
28
-    /**
29
-     * @param null $validation_error_message
30
-     * @param boolean $check_file_exists
31
-     * @param URLValidator $url_validator
32
-     * @throws InvalidArgumentException
33
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
34
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
35
-     */
36
-    public function __construct(
37
-        $validation_error_message = null,
38
-        $check_file_exists = false,
39
-        URLValidator $url_validator = null
40
-    ) {
41
-        if (! $url_validator instanceof URLValidator) {
42
-            $url_validator = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\validators\URLValidator');
43
-        }
44
-        $this->url_validator = $url_validator;
45
-        if (! $validation_error_message) {
46
-            $validation_error_message = esc_html__("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
47
-        }
48
-        $this->check_file_exists = $check_file_exists;
49
-        parent::__construct($validation_error_message);
50
-    }
28
+	/**
29
+	 * @param null $validation_error_message
30
+	 * @param boolean $check_file_exists
31
+	 * @param URLValidator $url_validator
32
+	 * @throws InvalidArgumentException
33
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
34
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
35
+	 */
36
+	public function __construct(
37
+		$validation_error_message = null,
38
+		$check_file_exists = false,
39
+		URLValidator $url_validator = null
40
+	) {
41
+		if (! $url_validator instanceof URLValidator) {
42
+			$url_validator = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\validators\URLValidator');
43
+		}
44
+		$this->url_validator = $url_validator;
45
+		if (! $validation_error_message) {
46
+			$validation_error_message = esc_html__("Please enter a valid URL. Eg https://eventespresso.com", "event_espresso");
47
+		}
48
+		$this->check_file_exists = $check_file_exists;
49
+		parent::__construct($validation_error_message);
50
+	}
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     * just checks the field isn't blank
56
-     *
57
-     * @param $normalized_value
58
-     * @return bool
59
-     * @throws \EE_Validation_Error
60
-     */
61
-    public function validate($normalized_value)
62
-    {
63
-        if ($normalized_value) {
64
-            if (! $this->url_validator->isValid($normalized_value)) {
65
-                throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
66
-            } elseif (apply_filters('FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', $this->check_file_exists, $this->_input)) {
67
-                if (
68
-                    ! EEH_URL::remote_file_exists(
69
-                        $normalized_value,
70
-                        array(
71
-                            'sslverify' => false,
72
-                            'limit_response_size' => 4095,// we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
73
-                        )
74
-                    )
75
-                ) {
76
-                    throw new EE_Validation_Error(sprintf(esc_html__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
77
-                }
78
-            }
79
-        }
80
-    }
54
+	/**
55
+	 * just checks the field isn't blank
56
+	 *
57
+	 * @param $normalized_value
58
+	 * @return bool
59
+	 * @throws \EE_Validation_Error
60
+	 */
61
+	public function validate($normalized_value)
62
+	{
63
+		if ($normalized_value) {
64
+			if (! $this->url_validator->isValid($normalized_value)) {
65
+				throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
66
+			} elseif (apply_filters('FHEE__EE_URL_Validation_Strategy__validate__check_remote_file_exists', $this->check_file_exists, $this->_input)) {
67
+				if (
68
+					! EEH_URL::remote_file_exists(
69
+						$normalized_value,
70
+						array(
71
+							'sslverify' => false,
72
+							'limit_response_size' => 4095,// we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
73
+						)
74
+					)
75
+				) {
76
+					throw new EE_Validation_Error(sprintf(esc_html__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
77
+				}
78
+			}
79
+		}
80
+	}
81 81
 
82 82
 
83 83
 
84
-    /**
85
-     * @return array
86
-     */
87
-    public function get_jquery_validation_rule_array()
88
-    {
89
-        return array( 'validUrl' => true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
90
-    }
84
+	/**
85
+	 * @return array
86
+	 */
87
+	public function get_jquery_validation_rule_array()
88
+	{
89
+		return array( 'validUrl' => true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
90
+	}
91 91
 }
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_Int_Validation_Strategy.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
      */
16 16
     public function __construct($validation_error_message = null)
17 17
     {
18
-        if (! $validation_error_message) {
18
+        if ( ! $validation_error_message) {
19 19
             $validation_error_message = esc_html__("Only digits are allowed.", "event_espresso");
20 20
         }
21 21
         parent::__construct($validation_error_message);
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Int_Validation_Strategy extends EE_Validation_Strategy_Base
11 11
 {
12
-    /**
13
-     * @param null $validation_error_message
14
-     */
15
-    public function __construct($validation_error_message = null)
16
-    {
17
-        if (! $validation_error_message) {
18
-            $validation_error_message = esc_html__("Only digits are allowed.", "event_espresso");
19
-        }
20
-        parent::__construct($validation_error_message);
21
-    }
12
+	/**
13
+	 * @param null $validation_error_message
14
+	 */
15
+	public function __construct($validation_error_message = null)
16
+	{
17
+		if (! $validation_error_message) {
18
+			$validation_error_message = esc_html__("Only digits are allowed.", "event_espresso");
19
+		}
20
+		parent::__construct($validation_error_message);
21
+	}
22 22
 
23 23
 
24 24
 
25
-    /**
26
-     * @param $normalized_value
27
-     */
28
-    public function validate($normalized_value)
29
-    {
30
-        // this should have already been detected by the normalization strategy
31
-    }
25
+	/**
26
+	 * @param $normalized_value
27
+	 */
28
+	public function validate($normalized_value)
29
+	{
30
+		// this should have already been detected by the normalization strategy
31
+	}
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * @return array
37
-     */
38
-    public function get_jquery_validation_rule_array()
39
-    {
40
-        return array(
41
-            'number' => true,
42
-            'step' => 1,
43
-            'messages' => array(
44
-                'number' => $this->get_validation_error_message(),
45
-                'step' => $this->get_validation_error_message()
46
-            )
47
-        );
48
-    }
35
+	/**
36
+	 * @return array
37
+	 */
38
+	public function get_jquery_validation_rule_array()
39
+	{
40
+		return array(
41
+			'number' => true,
42
+			'step' => 1,
43
+			'messages' => array(
44
+				'number' => $this->get_validation_error_message(),
45
+				'step' => $this->get_validation_error_message()
46
+			)
47
+		);
48
+	}
49 49
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Full_HTML_Validation_Strategy.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct($validation_error_message = null)
21 21
     {
22
-        if (! $validation_error_message) {
22
+        if ( ! $validation_error_message) {
23 23
             $validation_error_message = sprintf(
24 24
                 esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
25 25
                 '<br />',
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -13,62 +13,62 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base
15 15
 {
16
-    /**
17
-     * @param null $validation_error_message
18
-     */
19
-    public function __construct($validation_error_message = null)
20
-    {
21
-        if (! $validation_error_message) {
22
-            $validation_error_message = sprintf(
23
-                esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
24
-                '<br />',
25
-                $this->get_list_of_allowed_tags()
26
-            );
27
-        }
28
-        parent::__construct($validation_error_message);
29
-    }
16
+	/**
17
+	 * @param null $validation_error_message
18
+	 */
19
+	public function __construct($validation_error_message = null)
20
+	{
21
+		if (! $validation_error_message) {
22
+			$validation_error_message = sprintf(
23
+				esc_html__('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"),
24
+				'<br />',
25
+				$this->get_list_of_allowed_tags()
26
+			);
27
+		}
28
+		parent::__construct($validation_error_message);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * get_list_of_allowed_tags
34
-     *
35
-     * generates and returns a string that lists the top-level HTML tags that are allowable for this input
36
-     *
37
-     * @return string
38
-     */
39
-    public function get_list_of_allowed_tags()
40
-    {
41
-        $tags_we_allow = $this->getAllowedTags();
42
-        ksort($tags_we_allow);
43
-        return implode(', ', array_keys($tags_we_allow));
44
-    }
32
+	/**
33
+	 * get_list_of_allowed_tags
34
+	 *
35
+	 * generates and returns a string that lists the top-level HTML tags that are allowable for this input
36
+	 *
37
+	 * @return string
38
+	 */
39
+	public function get_list_of_allowed_tags()
40
+	{
41
+		$tags_we_allow = $this->getAllowedTags();
42
+		ksort($tags_we_allow);
43
+		return implode(', ', array_keys($tags_we_allow));
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * Returns an array whose keys are allowed tags and values are an array of allowed attributes
49
-     *
50
-     * @return array
51
-     */
52
-    protected function getAllowedTags()
53
-    {
54
-        global $allowedposttags;
55
-        return array_merge_recursive(
56
-            $allowedposttags,
57
-            EEH_HTML::get_simple_tags()
58
-        );
59
-    }
47
+	/**
48
+	 * Returns an array whose keys are allowed tags and values are an array of allowed attributes
49
+	 *
50
+	 * @return array
51
+	 */
52
+	protected function getAllowedTags()
53
+	{
54
+		global $allowedposttags;
55
+		return array_merge_recursive(
56
+			$allowedposttags,
57
+			EEH_HTML::get_simple_tags()
58
+		);
59
+	}
60 60
 
61 61
 
62
-    /**
63
-     * @param $normalized_value
64
-     * @throws \EE_Validation_Error
65
-     */
66
-    public function validate($normalized_value)
67
-    {
68
-        parent::validate($normalized_value);
69
-        $normalized_value_sans_tags = wp_kses("$normalized_value", $this->getAllowedTags());
70
-        if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
71
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
72
-        }
73
-    }
62
+	/**
63
+	 * @param $normalized_value
64
+	 * @throws \EE_Validation_Error
65
+	 */
66
+	public function validate($normalized_value)
67
+	{
68
+		parent::validate($normalized_value);
69
+		$normalized_value_sans_tags = wp_kses("$normalized_value", $this->getAllowedTags());
70
+		if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
71
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
72
+		}
73
+	}
74 74
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Credit_Card_Validation_Strategy.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct($validation_error_message = null)
21 21
     {
22
-        if (! $validation_error_message) {
22
+        if ( ! $validation_error_message) {
23 23
             $validation_error_message = esc_html__("Please enter a valid credit card number", "event_espresso");
24 24
         }
25 25
         parent::__construct(
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Credit_Card_Validation_Strategy extends EE_Text_Validation_Strategy
15 15
 {
16
-    /**
17
-     * @param null $validation_error_message
18
-     */
19
-    public function __construct($validation_error_message = null)
20
-    {
21
-        if (! $validation_error_message) {
22
-            $validation_error_message = esc_html__("Please enter a valid credit card number", "event_espresso");
23
-        }
24
-        parent::__construct(
25
-            $validation_error_message,
26
-            // @codingStandardsIgnoreStart
27
-            '~^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|2[2-7][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$~'
28
-            // @codingStandardsIgnoreEnd
29
-        );
30
-    }
16
+	/**
17
+	 * @param null $validation_error_message
18
+	 */
19
+	public function __construct($validation_error_message = null)
20
+	{
21
+		if (! $validation_error_message) {
22
+			$validation_error_message = esc_html__("Please enter a valid credit card number", "event_espresso");
23
+		}
24
+		parent::__construct(
25
+			$validation_error_message,
26
+			// @codingStandardsIgnoreStart
27
+			'~^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|2[2-7][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$~'
28
+			// @codingStandardsIgnoreEnd
29
+		);
30
+	}
31 31
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Enum_Validation_Strategy.strategy.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function validate($normalized_value)
23 23
     {
24 24
         parent::validate($normalized_value);
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26 26
             throw new EE_Error(sprintf(esc_html__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
27 27
         }
28 28
         $enum_options = $this->_input->flat_options();
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function get_validation_error_message()
50 50
     {
51 51
         $parent_validation_error_message = parent::get_validation_error_message();
52
-        if (! $parent_validation_error_message) {
52
+        if ( ! $parent_validation_error_message) {
53 53
             $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
54 54
             return sprintf(
55 55
                 esc_html__("This is not allowed option. Allowed options are %s.", "event_espresso"),
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,51 +11,51 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Enum_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14
-    /**
15
-     * Check that the value is in the allowed list
16
-     * @param $normalized_value
17
-     * @throws EE_Error
18
-     * @throws EE_Validation_Error
19
-     * @return boolean
20
-     */
21
-    public function validate($normalized_value)
22
-    {
23
-        parent::validate($normalized_value);
24
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
-            throw new EE_Error(sprintf(esc_html__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26
-        }
27
-        $enum_options = $this->_input->flat_options();
28
-        if ($normalized_value === true) {
29
-            $normalized_value = 1;
30
-        } elseif ($normalized_value === false) {
31
-            $normalized_value = 0;
32
-        }
33
-        if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
34
-            throw new EE_Validation_Error(
35
-                $this->get_validation_error_message(),
36
-                'invalid_enum_value'
37
-            );
38
-        } else {
39
-            return true;
40
-        }
41
-    }
14
+	/**
15
+	 * Check that the value is in the allowed list
16
+	 * @param $normalized_value
17
+	 * @throws EE_Error
18
+	 * @throws EE_Validation_Error
19
+	 * @return boolean
20
+	 */
21
+	public function validate($normalized_value)
22
+	{
23
+		parent::validate($normalized_value);
24
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+			throw new EE_Error(sprintf(esc_html__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26
+		}
27
+		$enum_options = $this->_input->flat_options();
28
+		if ($normalized_value === true) {
29
+			$normalized_value = 1;
30
+		} elseif ($normalized_value === false) {
31
+			$normalized_value = 0;
32
+		}
33
+		if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
34
+			throw new EE_Validation_Error(
35
+				$this->get_validation_error_message(),
36
+				'invalid_enum_value'
37
+			);
38
+		} else {
39
+			return true;
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * If we are using the default validation error message, make it dynamic based
45
-     * on the allowed options.
46
-     * @return string
47
-     */
48
-    public function get_validation_error_message()
49
-    {
50
-        $parent_validation_error_message = parent::get_validation_error_message();
51
-        if (! $parent_validation_error_message) {
52
-            $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53
-            return sprintf(
54
-                esc_html__("This is not allowed option. Allowed options are %s.", "event_espresso"),
55
-                implode(', ', $enum_options)
56
-            );
57
-        } else {
58
-            return $parent_validation_error_message;
59
-        }
60
-    }
43
+	/**
44
+	 * If we are using the default validation error message, make it dynamic based
45
+	 * on the allowed options.
46
+	 * @return string
47
+	 */
48
+	public function get_validation_error_message()
49
+	{
50
+		$parent_validation_error_message = parent::get_validation_error_message();
51
+		if (! $parent_validation_error_message) {
52
+			$enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53
+			return sprintf(
54
+				esc_html__("This is not allowed option. Allowed options are %s.", "event_espresso"),
55
+				implode(', ', $enum_options)
56
+			);
57
+		} else {
58
+			return $parent_validation_error_message;
59
+		}
60
+	}
61 61
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Required_Validation_Strategy.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct($validation_error_message = null)
21 21
     {
22
-        if (! $validation_error_message) {
22
+        if ( ! $validation_error_message) {
23 23
             $validation_error_message = esc_html__("This field is required.", "event_espresso");
24 24
         }
25 25
         parent::__construct($validation_error_message);
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -11,54 +11,54 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Required_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14
-    /**
15
-     * @param string $validation_error_message
16
-     */
17
-    public function __construct($validation_error_message = null)
18
-    {
19
-        if (! $validation_error_message) {
20
-            $validation_error_message = esc_html__("This field is required.", "event_espresso");
21
-        }
22
-        parent::__construct($validation_error_message);
23
-    }
14
+	/**
15
+	 * @param string $validation_error_message
16
+	 */
17
+	public function __construct($validation_error_message = null)
18
+	{
19
+		if (! $validation_error_message) {
20
+			$validation_error_message = esc_html__("This field is required.", "event_espresso");
21
+		}
22
+		parent::__construct($validation_error_message);
23
+	}
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * just checks the field isn't blank, provided the requirement conditions
29
-     * indicate this input is still required
30
-     *
31
-     * @param $normalized_value
32
-     * @return bool
33
-     * @throws \EE_Error
34
-     * @throws \EE_Validation_Error
35
-     */
36
-    public function validate($normalized_value)
37
-    {
38
-        if (
39
-            $normalized_value === ''
40
-            || $normalized_value === null
41
-            || $normalized_value === array()
42
-        ) {
43
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
44
-        } else {
45
-            return true;
46
-        }
47
-    }
27
+	/**
28
+	 * just checks the field isn't blank, provided the requirement conditions
29
+	 * indicate this input is still required
30
+	 *
31
+	 * @param $normalized_value
32
+	 * @return bool
33
+	 * @throws \EE_Error
34
+	 * @throws \EE_Validation_Error
35
+	 */
36
+	public function validate($normalized_value)
37
+	{
38
+		if (
39
+			$normalized_value === ''
40
+			|| $normalized_value === null
41
+			|| $normalized_value === array()
42
+		) {
43
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
44
+		} else {
45
+			return true;
46
+		}
47
+	}
48 48
 
49 49
 
50 50
 
51
-    /**
52
-     * @return array
53
-     * @throws \EE_Error
54
-     */
55
-    public function get_jquery_validation_rule_array()
56
-    {
57
-        return array(
58
-            'required' => true,
59
-            'messages' => array(
60
-                'required' => $this->get_validation_error_message()
61
-            )
62
-        );
63
-    }
51
+	/**
52
+	 * @return array
53
+	 * @throws \EE_Error
54
+	 */
55
+	public function get_jquery_validation_rule_array()
56
+	{
57
+		return array(
58
+			'required' => true,
59
+			'messages' => array(
60
+				'required' => $this->get_validation_error_message()
61
+			)
62
+		);
63
+	}
64 64
 }
Please login to merge, or discard this patch.