Code Duplication    Length = 20-20 lines in 2 locations

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

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