Code Duplication    Length = 10-12 lines in 2 locations

core/Container/Container.php 1 location

@@ 607-618 (lines=12) @@
604
	 * @param bool                $set_as_default (optional)
605
	 * @return Container $this
606
	 */
607
	public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) {
608
		if ( $set_as_default && ! $this->has_default_datastore() ) {
609
			return $this; // datastore has been overriden with a custom one - abort changing to a default one
610
		}
611
		$this->datastore = $datastore;
612
		$this->has_default_datastore = $set_as_default;
613
614
		foreach ( $this->fields as $field ) {
615
			$field->set_datastore( $this->get_datastore(), true );
616
		}
617
		return $this;
618
	}
619
620
	/**
621
	 * Get the DataStore instance

core/Field/Complex_Field.php 1 location

@@ 157-166 (lines=10) @@
154
	 * @param  boolean             $set_as_default
155
	 * @return self                $this
156
	 */
157
	public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) {
158
		if ( $set_as_default && ! $this->has_default_datastore() ) {
159
			return $this; // datastore has been overriden with a custom one - abort changing to a default one
160
		}
161
		$this->datastore = $datastore;
162
		$this->has_default_datastore = $set_as_default;
163
164
		$this->update_child_datastore( $this->get_datastore(), true );
165
		return $this;
166
	}
167
168
	/**
169
	 * Propagate the datastore down the hierarchy