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

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