Code Duplication    Length = 17-17 lines in 2 locations

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

@@ 431-447 (lines=17) @@
428
	 * @param  mixed  $empty_value
429
	 * @return mixed  The value specified for the option or a default value for the option.
430
	 */
431
	public function get_instance_option( $key, $empty_value = null ) {
432
		if ( empty( $this->instance_settings ) ) {
433
			$this->init_instance_settings();
434
		}
435
436
		// Get option default if unset.
437
		if ( ! isset( $this->instance_settings[ $key ] ) ) {
438
			$form_fields                     = $this->get_instance_form_fields();
439
			$this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] );
440
		}
441
442
		if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) {
443
			$this->instance_settings[ $key ] = $empty_value;
444
		}
445
446
		return $this->instance_settings[ $key ];
447
	}
448
449
	/**
450
	 * Get settings fields for instances of this shipping method (within zones).

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

@@ 247-263 (lines=17) @@
244
	 * @param  mixed  $empty_value
245
	 * @return string The value specified for the option or a default value for the option.
246
	 */
247
	public function get_option( $key, $empty_value = null ) {
248
		if ( empty( $this->settings ) ) {
249
			$this->init_settings();
250
		}
251
252
		// Get option default if unset.
253
		if ( ! isset( $this->settings[ $key ] ) ) {
254
			$form_fields            = $this->get_form_fields();
255
			$this->settings[ $key ] = isset( $form_fields[ $key ] ) ? $this->get_field_default( $form_fields[ $key ] ) : '';
256
		}
257
258
		if ( ! is_null( $empty_value ) && '' === $this->settings[ $key ] ) {
259
			$this->settings[ $key ] = $empty_value;
260
		}
261
262
		return $this->settings[ $key ];
263
	}
264
265
	/**
266
	 * Prefix key for settings.