prefer switch statements for complex logic, all comparing the same variable

This commit is contained in:
El RIDO 2022-01-24 17:48:27 +01:00
parent a8e1c33b54
commit 56c54dd880
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
1 changed files with 30 additions and 7 deletions

View File

@ -705,10 +705,14 @@ class Database extends AbstractData
private static function _getPrimaryKeyClauses($key = 'dataid') private static function _getPrimaryKeyClauses($key = 'dataid')
{ {
$main_key = $after_key = ''; $main_key = $after_key = '';
if (self::$_type === 'mysql' || self::$_type === 'oci') { switch (self::$_type) {
case 'mysql':
case 'oci':
$after_key = ", PRIMARY KEY (\"$key\")"; $after_key = ", PRIMARY KEY (\"$key\")";
} else { break;
default:
$main_key = ' PRIMARY KEY'; $main_key = ' PRIMARY KEY';
break;
} }
return array($main_key, $after_key); return array($main_key, $after_key);
} }
@ -724,7 +728,14 @@ class Database extends AbstractData
*/ */
private static function _getDataType() private static function _getDataType()
{ {
return self::$_type === 'pgsql' ? 'TEXT' : (self::$_type === 'oci' ? 'CLOB' : 'BLOB'); switch (self::$_type) {
case 'oci':
return 'CLOB';
case 'pgsql':
return 'TEXT';
default:
return 'BLOB';
}
} }
/** /**
@ -738,7 +749,14 @@ class Database extends AbstractData
*/ */
private static function _getAttachmentType() private static function _getAttachmentType()
{ {
return self::$_type === 'pgsql' ? 'TEXT' : (self::$_type === 'oci' ? 'CLOB' : 'MEDIUMBLOB'); switch (self::$_type) {
case 'oci':
return 'CLOB';
case 'pgsql':
return 'TEXT';
default:
return 'MEDIUMBLOB';
}
} }
/** /**
@ -752,7 +770,12 @@ class Database extends AbstractData
*/ */
private static function _getMetaType() private static function _getMetaType()
{ {
return self::$_type === 'oci' ? 'VARCHAR2(4000)' : 'TEXT'; switch (self::$_type) {
case 'oci':
return 'VARCHAR2(4000)';
default:
return 'TEXT';
}
} }
/** /**