Code Duplication    Length = 7-9 lines in 3 locations

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

@@ 199-205 (lines=7) @@
196
     */
197
    private function checkTableName($tableName = null)
198
    {
199
        if ($tableName === null) {
200
            if (count($this->dbRows) > 1) {
201
                throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
202
            } elseif (count($this->dbRows) === 1) {
203
                $tableName = array_keys($this->dbRows)[0];
204
            }
205
        }
206
207
        if (!isset($this->dbRows[$tableName])) {
208
            if (count($this->dbRows === 0)) {
@@ 227-235 (lines=9) @@
224
225
    protected function set($var, $value, $tableName = null)
226
    {
227
        if ($tableName === null) {
228
            if (count($this->dbRows) > 1) {
229
                throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
230
            } elseif (count($this->dbRows) === 1) {
231
                $tableName = array_keys($this->dbRows)[0];
232
            } else {
233
                throw new TDBMException('Please specify a table for this object.');
234
            }
235
        }
236
237
        if (!isset($this->dbRows[$tableName])) {
238
            $this->registerTable($tableName);
@@ 253-261 (lines=9) @@
250
     */
251
    protected function setRef($foreignKeyName, AbstractTDBMObject $bean = null, $tableName = null)
252
    {
253
        if ($tableName === null) {
254
            if (count($this->dbRows) > 1) {
255
                throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.');
256
            } elseif (count($this->dbRows) === 1) {
257
                $tableName = array_keys($this->dbRows)[0];
258
            } else {
259
                throw new TDBMException('Please specify a table for this object.');
260
            }
261
        }
262
263
        if (!isset($this->dbRows[$tableName])) {
264
            $this->registerTable($tableName);