| Conditions | 24 |
| Paths | 5632 |
| Total Lines | 51 |
| Code Lines | 38 |
| 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 |
||
| 41 | public function performAction($args) |
||
| 42 | { |
||
| 43 | $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
||
| 44 | $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false; |
||
| 45 | $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false; |
||
| 46 | $this->_prefix = count($args) > 5 ? $args[5] : ''; |
||
| 47 | $this->_postfix = count($args) > 6 ? $args[6] : ''; |
||
| 48 | |||
| 49 | if ($app_dir !== false) { |
||
| 50 | $config = $this->getActiveRecordConfig($app_dir); |
||
| 51 | |||
| 52 | $manager = TActiveRecordManager::getInstance(); |
||
| 53 | $con = $manager->getDbConnection(); |
||
| 54 | $con->Active = true; |
||
|
|
|||
| 55 | $command = null; |
||
| 56 | |||
| 57 | switch ($con->getDriverName()) { |
||
| 58 | case 'mysqli': |
||
| 59 | case 'mysql': |
||
| 60 | $command = $con->createCommand("SHOW TABLES"); |
||
| 61 | break; |
||
| 62 | case 'sqlite': //sqlite 3 |
||
| 63 | case 'sqlite2': //sqlite 2 |
||
| 64 | $command = $con->createCommand("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'"); |
||
| 65 | break; |
||
| 66 | case 'pgsql': |
||
| 67 | case 'mssql': // Mssql driver on windows hosts |
||
| 68 | case 'sqlsrv': // sqlsrv driver on windows hosts |
||
| 69 | case 'dblib': // dblib drivers on linux (and maybe others os) hosts |
||
| 70 | case 'oci': |
||
| 71 | // case 'ibm': |
||
| 72 | default: |
||
| 73 | echo "\n Sorry, generateAll is not implemented for " . $con->getDriverName() . "\n"; |
||
| 74 | |||
| 75 | } |
||
| 76 | |||
| 77 | $dataReader = $command->query(); |
||
| 78 | $dataReader->bindColumn(1, $table); |
||
| 79 | $tables = []; |
||
| 80 | while ($dataReader->read() !== false) { |
||
| 81 | $tables[] = $table; |
||
| 82 | } |
||
| 83 | $con->Active = false; |
||
| 84 | foreach ($tables as $key => $table) { |
||
| 85 | $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
||
| 86 | if ($config !== false && $output !== false) { |
||
| 87 | $this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | return true; |
||
| 92 | } |
||
| 175 |