| Conditions | 8 |
| Paths | 32 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 6 |
| Ratio | 23.08 % |
| Tests | 12 |
| CRAP Score | 10.3696 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 36 | protected function getTableName($table, $isForeignKey = false) |
|
| 35 | { |
||
| 36 | 36 | $tableName = ''; |
|
| 37 | |||
| 38 | 36 | if ($table instanceof \CI_Model) { |
|
| 39 | View Code Duplication | if (method_exists($newModel, 'getTableName')) { |
|
|
|
|||
| 40 | $tableName = $newModel->getTableName(); |
||
| 41 | } elseif (property_exists($newModel, 'table')) { |
||
| 42 | // NOTE: To be removed in v1.0.0 |
||
| 43 | $tableName = $newModel->table; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | 36 | if (! $isForeignKey && $this->table) { |
|
| 48 | 24 | $tableName = $this->table; |
|
| 49 | 24 | } |
|
| 50 | |||
| 51 | 36 | if (is_string($table)) { |
|
| 52 | 36 | $tableName = $table; |
|
| 53 | 36 | } |
|
| 54 | |||
| 55 | 36 | $tableName = ucfirst(singular($tableName)); |
|
| 56 | 36 | $array = explode('.', $tableName); |
|
| 57 | |||
| 58 | 36 | return isset($array[1]) ? $array[1] : $tableName; |
|
| 59 | } |
||
| 60 | |||
| 99 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.