Code Duplication    Length = 20-20 lines in 2 locations

src/Mouf/Database/TDBM/AbstractTDBMObject.php 2 locations

@@ 257-276 (lines=20) @@
254
		return $this->dbRows[$tableName]->has($var);
255
	}
256
	
257
	public function set($var, $value, $tableName = null) {
258
		if ($tableName === null) {
259
			if (count($this->dbRows) > 1) {
260
				throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
261
			} elseif (count($this->dbRows) === 1) {
262
				$tableName = array_keys($this->dbRows)[0];
263
			} else {
264
				throw new TDBMException("Please specify a table for this object.");
265
			}
266
		}
267
268
		if (!isset($this->dbRows[$tableName])) {
269
			$this->registerTable($tableName);
270
		}
271
272
		$this->dbRows[$tableName]->set($var, $value);
273
		if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) {
274
			$this->status = TDBMObjectStateEnum::STATE_DIRTY;
275
		}
276
	}
277
278
	/**
279
	 * @param string $foreignKeyName
@@ 282-301 (lines=20) @@
279
	 * @param string $foreignKeyName
280
	 * @param AbstractTDBMObject $bean
281
	 */
282
	public function setRef($foreignKeyName, AbstractTDBMObject $bean, $tableName = null) {
283
		if ($tableName === null) {
284
			if (count($this->dbRows) > 1) {
285
				throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
286
			} elseif (count($this->dbRows) === 1) {
287
				$tableName = array_keys($this->dbRows)[0];
288
			} else {
289
				throw new TDBMException("Please specify a table for this object.");
290
			}
291
		}
292
293
		if (!isset($this->dbRows[$tableName])) {
294
			$this->registerTable($tableName);
295
		}
296
297
		$this->dbRows[$tableName]->setRef($foreignKeyName, $bean);
298
		if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) {
299
			$this->status = TDBMObjectStateEnum::STATE_DIRTY;
300
		}
301
	}
302
303
	/**
304
	 * @param string $foreignKeyName A unique name for this reference