| Conditions | 10 |
| Paths | 14 |
| Total Lines | 35 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 88 | protected function parseTables(array $tables = null, array $not = null):array{ |
||
| 89 | $q = $this->query->show->tables()->query()->__toArray(); |
||
| 90 | $r = []; |
||
| 91 | $st = []; |
||
| 92 | |||
| 93 | foreach($q as $t){ |
||
| 94 | [$table] = array_values($t); |
||
| 95 | $st[] = $table; |
||
| 96 | } |
||
| 97 | |||
| 98 | if(empty($tables) && empty($not)){ |
||
| 99 | return $st; |
||
| 100 | } |
||
| 101 | |||
| 102 | foreach($tables as $expression){ |
||
| 103 | $x = explode('*', $expression, 2); |
||
| 104 | |||
| 105 | foreach($st as $table){ |
||
| 106 | |||
| 107 | if(count($x) === 2){ |
||
| 108 | |||
| 109 | if(strpos($table, $x[0]) === 0 && !in_array($table, $not, true)){ |
||
| 110 | $r[] = $table; |
||
| 111 | } |
||
| 112 | |||
| 113 | } |
||
| 114 | elseif($expression === $table){ |
||
| 115 | $r[] = $table; |
||
| 116 | } |
||
| 117 | |||
| 118 | } |
||
| 119 | |||
| 120 | } |
||
| 121 | |||
| 122 | return $r; |
||
| 123 | } |
||
| 125 |