| Conditions | 4 |
| Paths | 4 |
| Total Lines | 107 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 namespace XoopsModules\Mymenus; |
||
| 36 | public static function checkInfoTable(\XoopsObject $module) |
||
| 37 | { |
||
| 38 | // global $xoopsDB; |
||
| 39 | $err = true; |
||
| 40 | |||
| 41 | $tables_menus = [ |
||
| 42 | 'id' => 'int(5) NOT NULL auto_increment', |
||
| 43 | 'title' => "varchar(255) NOT NULL default ''", |
||
| 44 | 'css' => "varchar(255) NOT NULL default ''" |
||
| 45 | ]; |
||
| 46 | |||
| 47 | $tables_links = [ |
||
| 48 | 'id' => 'int(5) NOT NULL auto_increment', |
||
| 49 | 'pid' => "int(5) NOT NULL default '0'", |
||
| 50 | 'mid' => "int(5) NOT NULL default '0'", |
||
| 51 | 'title' => "varchar(150) NOT NULL default ''", |
||
| 52 | 'alt_title' => "varchar(255) NOT NULL default ''", |
||
| 53 | 'visible' => "tinyint(1) NOT NULL default '0'", |
||
| 54 | 'link' => 'varchar(255) default NULL', |
||
| 55 | 'weight' => "tinyint(4) NOT NULL default '0'", |
||
| 56 | 'target' => 'varchar(10) default NULL', |
||
| 57 | 'groups' => 'text default NULL', |
||
| 58 | 'hooks' => 'text default NULL', |
||
| 59 | 'image' => 'varchar(255) default NULL', |
||
| 60 | 'css' => 'varchar(255) default NULL' |
||
| 61 | ]; |
||
| 62 | |||
| 63 | /* |
||
| 64 | |||
| 65 | // CREATE or ALTER 'mymenus_menus' table |
||
| 66 | if (!InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus')) { |
||
| 67 | $sql = "CREATE TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus ("; |
||
| 68 | foreach ($tables_menus as $s => $w) { |
||
| 69 | $sql .= " " . $s . " " . $w . ","; |
||
| 70 | } |
||
| 71 | $sql .= " PRIMARY KEY (id)); "; |
||
| 72 | echo $sql; |
||
| 73 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 74 | if (!$result) { |
||
| 75 | $module->setErrors("Can't create Table " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus'); |
||
| 76 | return false; |
||
| 77 | } else { |
||
| 78 | $sql = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus (id,title) VALUES (1,'Default')"; |
||
| 79 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 80 | } |
||
| 81 | } else { |
||
| 82 | foreach ($tables_menus as $s => $w) { |
||
| 83 | if (!InfoColumnExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus', $s)) { |
||
| 84 | $sql = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus ADD " . $s . " " . $w . ";"; |
||
| 85 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 86 | } else { |
||
| 87 | $sql = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_menus CHANGE " . $s . " " . $s . " " . $w . ";"; |
||
| 88 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 89 | } |
||
| 90 | } |
||
| 91 | } |
||
| 92 | */ |
||
| 93 | |||
| 94 | self::createUpdateTable($tables_menus, '_menus', $module); |
||
| 95 | |||
| 96 | // RENAME TABLE 'mymenus_menu' TO 'mymenus_links' |
||
| 97 | if (!InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_links')) { |
||
| 98 | if (InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_menu')) { |
||
| 99 | $sql = 'RENAME TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_menu TO ' . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_links;'; |
||
| 100 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 101 | if (!$result) { |
||
| 102 | $module->setErrors("Can't rename Table " . $GLOBALS['xoopsDB']->prefix($module->getInfo('dirname')) . '_menu'); |
||
| 103 | |||
| 104 | return false; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | } |
||
| 108 | |||
| 109 | /* |
||
| 110 | //--------------------------- |
||
| 111 | // CREATE or ALTER 'mymenus_links' table |
||
| 112 | if (!InfoTableExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links")) { |
||
| 113 | $sql = "CREATE TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links ( "; |
||
| 114 | foreach ($tables_links as $c => $w) { |
||
| 115 | $sql .= " " . $c . " " . $w . ","; |
||
| 116 | } |
||
| 117 | $sql .= " PRIMARY KEY (id) ) ;"; |
||
| 118 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 119 | if (!$result) { |
||
| 120 | $module->setErrors("Can't create Table " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links"); |
||
| 121 | $sql = 'DROP TABLE ' . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_menus'; |
||
| 122 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 123 | return false; |
||
| 124 | } |
||
| 125 | } else { |
||
| 126 | foreach ($tables_links as $s => $w) { |
||
| 127 | if (!InfoColumnExists($GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . '_links', $s)) { |
||
| 128 | $sql = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links ADD " . $s . " " . $w . ";"; |
||
| 129 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 130 | } else { |
||
| 131 | $sql = "ALTER TABLE " . $GLOBALS['xoopsDB']->prefix($module->getInfo("dirname")) . "_links CHANGE " . $s . " " . $s . " " . $w . ";"; |
||
| 132 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||
| 133 | } |
||
| 134 | } |
||
| 135 | } |
||
| 136 | |||
| 137 | //-------------------------- |
||
| 138 | */ |
||
| 139 | |||
| 140 | self::createUpdateTable($tables_links, '_links', $module); |
||
| 141 | |||
| 142 | return true; |
||
| 143 | } |
||
| 195 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths