Code Duplication    Length = 10-14 lines in 2 locations

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.

core/Field/Field.php 1 location

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