Code Duplication    Length = 20-20 lines in 2 locations

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

@@ 242-261 (lines=20) @@
239
     * @param string             $foreignKeyName
240
     * @param AbstractTDBMObject $bean
241
     */
242
    protected function setRef($foreignKeyName, AbstractTDBMObject $bean, $tableName = null)
243
    {
244
        if ($tableName === null) {
245
            if (count($this->dbRows) > 1) {
246
                throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
247
            } elseif (count($this->dbRows) === 1) {
248
                $tableName = array_keys($this->dbRows)[0];
249
            } else {
250
                throw new TDBMException('Please specify a table for this object.');
251
            }
252
        }
253
254
        if (!isset($this->dbRows[$tableName])) {
255
            $this->registerTable($tableName);
256
        }
257
258
        $this->dbRows[$tableName]->setRef($foreignKeyName, $bean);
259
        if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) {
260
            $this->status = TDBMObjectStateEnum::STATE_DIRTY;
261
        }
262
    }
263
264
    /**
@@ 216-235 (lines=20) @@
213
        return $this->dbRows[$tableName]->get($var);
214
    }
215
216
    protected function set($var, $value, $tableName = null)
217
    {
218
        if ($tableName === null) {
219
            if (count($this->dbRows) > 1) {
220
                throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
221
            } elseif (count($this->dbRows) === 1) {
222
                $tableName = array_keys($this->dbRows)[0];
223
            } else {
224
                throw new TDBMException('Please specify a table for this object.');
225
            }
226
        }
227
228
        if (!isset($this->dbRows[$tableName])) {
229
            $this->registerTable($tableName);
230
        }
231
232
        $this->dbRows[$tableName]->set($var, $value);
233
        if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) {
234
            $this->status = TDBMObjectStateEnum::STATE_DIRTY;
235
        }
236
    }
237
238
    /**