Code Duplication    Length = 20-20 lines in 2 locations

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

@@ 201-220 (lines=20) @@
198
        return $this->dbRows[$tableName]->get($var);
199
    }
200
201
    protected function set($var, $value, $tableName = null)
202
    {
203
        if ($tableName === null) {
204
            if (count($this->dbRows) > 1) {
205
                throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
206
            } elseif (count($this->dbRows) === 1) {
207
                $tableName = array_keys($this->dbRows)[0];
208
            } else {
209
                throw new TDBMException('Please specify a table for this object.');
210
            }
211
        }
212
213
        if (!isset($this->dbRows[$tableName])) {
214
            $this->registerTable($tableName);
215
        }
216
217
        $this->dbRows[$tableName]->set($var, $value);
218
        if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) {
219
            $this->status = TDBMObjectStateEnum::STATE_DIRTY;
220
        }
221
    }
222
223
    /**
@@ 227-246 (lines=20) @@
224
     * @param string             $foreignKeyName
225
     * @param AbstractTDBMObject $bean
226
     */
227
    protected function setRef($foreignKeyName, AbstractTDBMObject $bean, $tableName = null)
228
    {
229
        if ($tableName === null) {
230
            if (count($this->dbRows) > 1) {
231
                throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
232
            } elseif (count($this->dbRows) === 1) {
233
                $tableName = array_keys($this->dbRows)[0];
234
            } else {
235
                throw new TDBMException('Please specify a table for this object.');
236
            }
237
        }
238
239
        if (!isset($this->dbRows[$tableName])) {
240
            $this->registerTable($tableName);
241
        }
242
243
        $this->dbRows[$tableName]->setRef($foreignKeyName, $bean);
244
        if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) {
245
            $this->status = TDBMObjectStateEnum::STATE_DIRTY;
246
        }
247
    }
248
249
    /**