Code Duplication    Length = 10-12 lines in 2 locations

core/Field/Group_Field.php 1 location

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

core/Field/Field.php 1 location

@@ 209-220 (lines=12) @@
206
	 * @param string $name  Field name
207
	 * @param string $label Field label
208
	 */
209
	protected function __construct( $name, $label ) {
210
		$this->set_name( $name );
211
		$this->set_label( $label );
212
		$this->set_base_name( $name );
213
214
		// Pick random ID
215
		$random_string = md5( mt_rand() . $this->get_name() . $this->get_label() );
216
		$random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough
217
		$this->id = 'carbon-' . $random_string;
218
219
		$this->init();
220
	}
221
222
	/**
223
	 * Boot the field once the container is attached.