Code Duplication    Length = 17-17 lines in 2 locations

includes/abstracts/abstract-wc-settings-api.php 1 location

@@ 208-224 (lines=17) @@
205
	 * @param  mixed  $empty_value
206
	 * @return mixed  The value specified for the option or a default value for the option.
207
	 */
208
	public function get_option( $key, $empty_value = null ) {
209
		if ( empty( $this->settings ) ) {
210
			$this->init_settings();
211
		}
212
213
		// Get option default if unset.
214
		if ( ! isset( $this->settings[ $key ] ) ) {
215
			$form_fields            = $this->get_form_fields();
216
			$this->settings[ $key ] = isset( $form_fields[ $key ] ) ? $this->get_field_default( $form_fields[ $key ] ) : '';
217
		}
218
219
		if ( ! is_null( $empty_value ) && '' === $this->settings[ $key ] ) {
220
			$this->settings[ $key ] = $empty_value;
221
		}
222
223
		return $this->settings[ $key ];
224
	}
225
226
	/**
227
	 * Prefix key for settings.

includes/abstracts/abstract-wc-shipping-method.php 1 location

@@ 410-426 (lines=17) @@
407
	 * @param  mixed  $empty_value
408
	 * @return mixed  The value specified for the option or a default value for the option.
409
	 */
410
	public function get_instance_option( $key, $empty_value = null ) {
411
		if ( empty( $this->instance_settings ) ) {
412
			$this->init_instance_settings();
413
		}
414
415
		// Get option default if unset.
416
		if ( ! isset( $this->instance_settings[ $key ] ) ) {
417
			$form_fields                     = $this->get_instance_form_fields();
418
			$this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] );
419
		}
420
421
		if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) {
422
			$this->instance_settings[ $key ] = $empty_value;
423
		}
424
425
		return $this->instance_settings[ $key ];
426
	}
427
428
	/**
429
	 * Get settings fields for instances of this shipping method (within zones).