Code Duplication    Length = 10-12 lines in 2 locations

core/Container/Container.php 1 location

@@ 565-576 (lines=12) @@
562
	 * @param Datastore_Interface $datastore
563
	 * @return object $this
564
	 */
565
	public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) {
566
		if ( $set_as_default && ! $this->has_default_datastore() ) {
567
			return $this; // datastore has been overriden with a custom one - abort changing to a default one
568
		}
569
		$this->datastore = $datastore;
570
		$this->has_default_datastore = $set_as_default;
571
572
		foreach ( $this->fields as $field ) {
573
			$field->set_datastore( $this->get_datastore(), true );
574
		}
575
		return $this;
576
	}
577
578
	/**
579
	 * Get the DataStore instance

core/Field/Complex_Field.php 1 location

@@ 149-158 (lines=10) @@
146
	 * @param  boolean             $set_as_default
147
	 * @return object              $this
148
	 */
149
	public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) {
150
		if ( $set_as_default && ! $this->has_default_datastore() ) {
151
			return $this; // datastore has been overriden with a custom one - abort changing to a default one
152
		}
153
		$this->datastore = $datastore;
154
		$this->has_default_datastore = $set_as_default;
155
156
		$this->update_child_datastore( $this->get_datastore(), true );
157
		return $this;
158
	}
159
160
	/**
161
	 * Propagate the datastore down the hierarchy