summaryrefslogtreecommitdiffstats
path: root/src/Utils/Table.php
diff options
context:
space:
mode:
authorDeven Bansod <devenbansod@users.noreply.github.com>2018-12-09 15:51:22 +0530
committerGitHub <noreply@github.com>2018-12-09 15:51:22 +0530
commit5e8dbcf3ff0d1123efd731863083a9af539e5992 (patch)
treeb60470ba4a628ee748310403dd71caad46101968 /src/Utils/Table.php
parentad6a0ce1efcde74726e28e9b3da9ffad3fc4c474 (diff)
parent4b3684f16ecb3539057cbba3141473c059141a45 (diff)
downloadsql-parser-5e8dbcf3ff0d1123efd731863083a9af539e5992.zip
sql-parser-5e8dbcf3ff0d1123efd731863083a9af539e5992.tar.gz
sql-parser-5e8dbcf3ff0d1123efd731863083a9af539e5992.tar.bz2
Merge pull request #206 from bperel/cleanup
Cleanup the code * Avoid duplicate if conditions * Use switch/case instead of ifs when possible * Use triple (in)equalities when type compatibility is ensured
Diffstat (limited to 'src/Utils/Table.php')
-rw-r--r--src/Utils/Table.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Utils/Table.php b/src/Utils/Table.php
index 7624974..b90c17a 100644
--- a/src/Utils/Table.php
+++ b/src/Utils/Table.php
@@ -26,7 +26,7 @@ class Table
*/
public static function getForeignKeys($statement)
{
- if ((empty($statement->fields))
+ if (empty($statement->fields)
|| (!is_array($statement->fields))
|| (!$statement->options->has('TABLE'))
) {
@@ -36,7 +36,7 @@ class Table
$ret = array();
foreach ($statement->fields as $field) {
- if ((empty($field->key)) || ($field->key->type !== 'FOREIGN KEY')) {
+ if (empty($field->key) || ($field->key->type !== 'FOREIGN KEY')) {
continue;
}
@@ -55,11 +55,11 @@ class Table
$tmp['ref_table_name'] = $field->references->table->table;
$tmp['ref_index_list'] = $field->references->columns;
- if (($opt = $field->references->options->has('ON UPDATE'))) {
+ if ($opt = $field->references->options->has('ON UPDATE')) {
$tmp['on_update'] = str_replace(' ', '_', $opt);
}
- if (($opt = $field->references->options->has('ON DELETE'))) {
+ if ($opt = $field->references->options->has('ON DELETE')) {
$tmp['on_delete'] = str_replace(' ', '_', $opt);
}
@@ -83,7 +83,7 @@ class Table
*/
public static function getFields($statement)
{
- if ((empty($statement->fields))
+ if (empty($statement->fields)
|| (!is_array($statement->fields))
|| (!$statement->options->has('TABLE'))
) {
@@ -110,20 +110,20 @@ class Table
}
}
- if (($option = $field->options->has('DEFAULT'))) {
+ if ($option = $field->options->has('DEFAULT')) {
$ret[$field->name]['default_value'] = $option;
if ($option === 'CURRENT_TIMESTAMP') {
$ret[$field->name]['default_current_timestamp'] = true;
}
}
- if (($option = $field->options->has('ON UPDATE'))) {
+ if ($option = $field->options->has('ON UPDATE')) {
if ($option === 'CURRENT_TIMESTAMP') {
$ret[$field->name]['on_update_current_timestamp'] = true;
}
}
- if (($option = $field->options->has('AS'))) {
+ if ($option = $field->options->has('AS')) {
$ret[$field->name]['generated'] = true;
$ret[$field->name]['expr'] = $option;
}