Code Duplication    Length = 8-9 lines in 2 locations

core/Field/Complex_Field.php 1 location

@@ 362-370 (lines=9) @@
359
	 * Generate and set the field prefix.
360
	 * @param string $prefix
361
	 */
362
	public function set_prefix($prefix) {
363
		$this->name = preg_replace( '~^' . preg_quote( $this->name_prefix, '~' ) . '~', '', $this->name );
364
		$this->name_prefix = $prefix;
365
		$this->name = $this->name_prefix . $this->name;
366
367
		foreach ( $this->groups as $group ) {
368
			$group->set_prefix( $prefix );
369
		}
370
	}
371
372
	/**
373
	 * Returns an array that holds the field data, suitable for JSON representation.

core/Field/Field.php 1 location

@@ 429-436 (lines=8) @@
426
	 * @param string $prefix
427
	 * @return object $this
428
	 **/
429
	public function set_prefix( $prefix ) {
430
		$escaped_prefix = preg_quote( $this->name_prefix, '~' );
431
		$this->name = preg_replace( '~^' . $escaped_prefix . '~', '', $this->name );
432
		$this->name_prefix = $prefix;
433
		$this->name = $this->name_prefix . $this->name;
434
435
		return $this;
436
	}
437
438
	/**
439
	 * Set field label.