Code Duplication    Length = 10-14 lines in 2 locations

core/Field/Field.php 1 location

@@ 242-255 (lines=14) @@
239
	 * @param string $name  Field name
240
	 * @param string $label Field label
241
	 */
242
	protected function __construct( $name, $label ) {
243
		App::verify_boot();
244
		
245
		$this->set_base_name( $name );
246
		$this->set_name( $name );
247
		$this->set_label( $label );
248
249
		// Pick random ID
250
		$random_string = md5( mt_rand() . $this->get_name() . $this->get_label() );
251
		$random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough
252
		$this->id = 'carbon-' . $random_string;
253
254
		$this->init();
255
	}
256
257
	/**
258
	 * Activate the field once the container is attached.

core/Field/Group_Field.php 1 location

@@ 62-71 (lines=10) @@
59
	 * @param string $label
60
	 * @param array  $fields
61
	 */
62
	public function __construct( $name, $label, $fields ) {
63
		$this->set_name( $name );
64
		$this->set_label( $label );
65
		$this->add_fields( $fields );
66
67
		// Pick random ID
68
		$random_string = md5( mt_rand() . $this->get_name() . $this->get_label() );
69
		$random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough
70
		$this->group_id = 'carbon-group-' . $random_string;
71
	}
72
73
	/**
74
	 * Add a group of fields.