Completed
Pull Request — master (#29)
by
unknown
02:40
created
src/Columns.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@
 block discarded – undo
144 144
    *
145 145
    * @param string $columnName The column name.
146 146
    *
147
-   * @return null|string
147
+   * @return integer|null
148 148
    */
149 149
   public function getPreviousColumn($columnName)
150 150
   {
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -8,179 +8,179 @@
 block discarded – undo
8 8
  */
9 9
 class Columns
10 10
 {
11
-  //--------------------------------------------------------------------------------------------------------------------
12
-  /**
13
-   * The metadata of the columns.
14
-   *
15
-   * @var array[]
16
-   */
17
-  private $columns = [];
18
-
19
-  //--------------------------------------------------------------------------------------------------------------------
20
-  /**
21
-   * Object constructor.
22
-   *
23
-   * @param array[] $columns The metadata of the columns.
24
-   */
25
-  public function __construct($columns)
26
-  {
11
+    //--------------------------------------------------------------------------------------------------------------------
12
+    /**
13
+     * The metadata of the columns.
14
+     *
15
+     * @var array[]
16
+     */
17
+    private $columns = [];
18
+
19
+    //--------------------------------------------------------------------------------------------------------------------
20
+    /**
21
+     * Object constructor.
22
+     *
23
+     * @param array[] $columns The metadata of the columns.
24
+     */
25
+    public function __construct($columns)
26
+    {
27 27
     foreach ($columns as $column)
28 28
     {
29
-      $columnTypes                           = new ColumnTypes($column);
30
-      $this->columns[$column['column_name']] = $columnTypes->getTypes();
29
+        $columnTypes                           = new ColumnTypes($column);
30
+        $this->columns[$column['column_name']] = $columnTypes->getTypes();
31
+    }
31 32
     }
32
-  }
33
-
34
-  //--------------------------------------------------------------------------------------------------------------------
35
-  /**
36
-   * Generate array with audit columns and columns from data table.
37
-   *
38
-   * @param Columns $auditColumnsMetadata   AuditApplication columns for adding to exist columns
39
-   * @param Columns $currentColumnsMetadata Exist table columns
40
-   *
41
-   * @return Columns
42
-   */
43
-  public static function combine($auditColumnsMetadata, $currentColumnsMetadata)
44
-  {
33
+
34
+    //--------------------------------------------------------------------------------------------------------------------
35
+    /**
36
+     * Generate array with audit columns and columns from data table.
37
+     *
38
+     * @param Columns $auditColumnsMetadata   AuditApplication columns for adding to exist columns
39
+     * @param Columns $currentColumnsMetadata Exist table columns
40
+     *
41
+     * @return Columns
42
+     */
43
+    public static function combine($auditColumnsMetadata, $currentColumnsMetadata)
44
+    {
45 45
     $columns = [];
46 46
 
47 47
     foreach ($auditColumnsMetadata->columns as $column)
48 48
     {
49
-      $columns[] = ['column_name' => $column['column_name'],
49
+        $columns[] = ['column_name' => $column['column_name'],
50 50
                     'column_type' => $column['column_type']];
51 51
     }
52 52
 
53 53
     foreach ($currentColumnsMetadata->columns as $column)
54 54
     {
55
-      if ($column['column_type']!='timestamp')
56
-      {
55
+        if ($column['column_type']!='timestamp')
56
+        {
57 57
         $columns[] = ['column_name' => $column['column_name'],
58
-                      'column_type' => $column['column_type']];
59
-      }
60
-      else
61
-      {
58
+                        'column_type' => $column['column_type']];
59
+        }
60
+        else
61
+        {
62 62
         $columns[] = ['column_name' => $column['column_name'],
63
-                      'column_type' => $column['column_type'].' NULL'];
64
-      }
63
+                        'column_type' => $column['column_type'].' NULL'];
64
+        }
65 65
     }
66 66
 
67 67
     return new Columns($columns);
68
-  }
69
-
70
-  //--------------------------------------------------------------------------------------------------------------------
71
-  /**
72
-   * Compares two Columns objects and returns an array with columns that are in the first columns object and in the
73
-   * second Columns object but have different types.
74
-   *
75
-   * @param Columns $columns1 The first Columns object.
76
-   * @param Columns $columns2 The second Columns object.
77
-   *
78
-   * @return Columns
79
-   */
80
-  public static function differentColumnTypes($columns1, $columns2)
81
-  {
68
+    }
69
+
70
+    //--------------------------------------------------------------------------------------------------------------------
71
+    /**
72
+     * Compares two Columns objects and returns an array with columns that are in the first columns object and in the
73
+     * second Columns object but have different types.
74
+     *
75
+     * @param Columns $columns1 The first Columns object.
76
+     * @param Columns $columns2 The second Columns object.
77
+     *
78
+     * @return Columns
79
+     */
80
+    public static function differentColumnTypes($columns1, $columns2)
81
+    {
82 82
     $diff = [];
83 83
     foreach ($columns2->columns as $column2)
84 84
     {
85
-      if (isset($columns1->columns[$column2['column_name']]))
86
-      {
85
+        if (isset($columns1->columns[$column2['column_name']]))
86
+        {
87 87
         $column1 = $columns1->columns[$column2['column_name']];
88 88
         if ($column2['column_type']!=$column1['column_type'])
89 89
         {
90
-          $diff[] = $column1;
90
+            $diff[] = $column1;
91
+        }
91 92
         }
92
-      }
93 93
     }
94 94
 
95 95
     return new Columns($diff);
96
-  }
97
-
98
-  //--------------------------------------------------------------------------------------------------------------------
99
-  /**
100
-   * Compares two Columns objects and returns an array with columns that are in the first columns object but not in the
101
-   * second Columns object.
102
-   *
103
-   * @param Columns $columns1 The first Columns object.
104
-   * @param Columns $columns2 The second Columns object.
105
-   *
106
-   * @return Columns
107
-   */
108
-  public static function notInOtherSet($columns1, $columns2)
109
-  {
96
+    }
97
+
98
+    //--------------------------------------------------------------------------------------------------------------------
99
+    /**
100
+     * Compares two Columns objects and returns an array with columns that are in the first columns object but not in the
101
+     * second Columns object.
102
+     *
103
+     * @param Columns $columns1 The first Columns object.
104
+     * @param Columns $columns2 The second Columns object.
105
+     *
106
+     * @return Columns
107
+     */
108
+    public static function notInOtherSet($columns1, $columns2)
109
+    {
110 110
     $diff = [];
111 111
     if (isset($columns1))
112 112
     {
113
-      foreach ($columns1->columns as $column1)
114
-      {
113
+        foreach ($columns1->columns as $column1)
114
+        {
115 115
         if (!isset($columns2->columns[$column1['column_name']]))
116 116
         {
117
-          $diff[] = ['column_name' => $column1['column_name'],
118
-                     'column_type' => $column1['column_type']];
117
+            $diff[] = ['column_name' => $column1['column_name'],
118
+                        'column_type' => $column1['column_type']];
119
+        }
119 120
         }
120
-      }
121 121
     }
122 122
 
123 123
     return new Columns($diff);
124
-  }
125
-
126
-  //--------------------------------------------------------------------------------------------------------------------
127
-  /**
128
-   * Returns the underlying array with metadata of the columns.
129
-   *
130
-   * @return array[]
131
-   */
132
-  public function getColumns()
133
-  {
124
+    }
125
+
126
+    //--------------------------------------------------------------------------------------------------------------------
127
+    /**
128
+     * Returns the underlying array with metadata of the columns.
129
+     *
130
+     * @return array[]
131
+     */
132
+    public function getColumns()
133
+    {
134 134
     return $this->columns;
135
-  }
136
-
137
-  //--------------------------------------------------------------------------------------------------------------------
138
-  /**
139
-   * Return column type with character set and collation.
140
-   *
141
-   * @param string $columnName The column name.
142
-   *
143
-   * @return null|string
144
-   */
145
-  public function getColumnTypeWithCharSetCollation($columnName)
146
-  {
135
+    }
136
+
137
+    //--------------------------------------------------------------------------------------------------------------------
138
+    /**
139
+     * Return column type with character set and collation.
140
+     *
141
+     * @param string $columnName The column name.
142
+     *
143
+     * @return null|string
144
+     */
145
+    public function getColumnTypeWithCharSetCollation($columnName)
146
+    {
147 147
     $columns = array_keys($this->columns);
148 148
     $key     = array_search($columnName, $columns);
149 149
 
150 150
     if ($key!==false)
151 151
     {
152
-      $column                       = $this->columns[$columns[$key]];
153
-      $column['character_set_name'] = isset($column['character_set_name']) ? ' '.$column['character_set_name'] : '';
154
-      $column['collation_name']     = isset($column['collation_name']) ? ' '.$column['collation_name'] : '';
152
+        $column                       = $this->columns[$columns[$key]];
153
+        $column['character_set_name'] = isset($column['character_set_name']) ? ' '.$column['character_set_name'] : '';
154
+        $column['collation_name']     = isset($column['collation_name']) ? ' '.$column['collation_name'] : '';
155 155
 
156
-      return sprintf('%s%s%s', $column['column_type'], $column['character_set_name'], $column['collation_name']);
156
+        return sprintf('%s%s%s', $column['column_type'], $column['character_set_name'], $column['collation_name']);
157 157
     }
158 158
 
159 159
     return null;
160
-  }
161
-
162
-  //--------------------------------------------------------------------------------------------------------------------
163
-  /**
164
-   * Returns previous column of a columns. Returns null if the column name is not found in this Columns.
165
-   *
166
-   * @param string $columnName The column name.
167
-   *
168
-   * @return null|string
169
-   */
170
-  public function getPreviousColumn($columnName)
171
-  {
160
+    }
161
+
162
+    //--------------------------------------------------------------------------------------------------------------------
163
+    /**
164
+     * Returns previous column of a columns. Returns null if the column name is not found in this Columns.
165
+     *
166
+     * @param string $columnName The column name.
167
+     *
168
+     * @return null|string
169
+     */
170
+    public function getPreviousColumn($columnName)
171
+    {
172 172
     $columns = array_keys($this->columns);
173 173
     $key     = array_search($columnName, $columns);
174 174
 
175 175
     if ($key>=1)
176 176
     {
177
-      return $columns[$key - 1];
177
+        return $columns[$key - 1];
178 178
     }
179 179
 
180 180
     return null;
181
-  }
181
+    }
182 182
 
183
-  //--------------------------------------------------------------------------------------------------------------------
183
+    //--------------------------------------------------------------------------------------------------------------------
184 184
 }
185 185
 
186 186
 //----------------------------------------------------------------------------------------------------------------------
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
     foreach ($currentColumnsMetadata->columns as $column)
54 54
     {
55
-      if ($column['column_type']!='timestamp')
55
+      if ($column['column_type'] != 'timestamp')
56 56
       {
57 57
         $columns[] = ['column_name' => $column['column_name'],
58 58
                       'column_type' => $column['column_type']];
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
       if (isset($columns1->columns[$column2['column_name']]))
86 86
       {
87 87
         $column1 = $columns1->columns[$column2['column_name']];
88
-        if ($column2['column_type']!=$column1['column_type'])
88
+        if ($column2['column_type'] != $column1['column_type'])
89 89
         {
90 90
           $diff[] = $column1;
91 91
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     $columns = array_keys($this->columns);
148 148
     $key     = array_search($columnName, $columns);
149 149
 
150
-    if ($key!==false)
150
+    if ($key !== false)
151 151
     {
152 152
       $column                       = $this->columns[$columns[$key]];
153 153
       $column['character_set_name'] = isset($column['character_set_name']) ? ' '.$column['character_set_name'] : '';
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     $columns = array_keys($this->columns);
173 173
     $key     = array_search($columnName, $columns);
174 174
 
175
-    if ($key>=1)
175
+    if ($key >= 1)
176 176
     {
177 177
       return $columns[$key - 1];
178 178
     }
Please login to merge, or discard this patch.
src/ColumnTypes.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
   {
42 42
     foreach ($columnTypes as $typeName => $typeValue)
43 43
     {
44
-      if ($typeName=='column_name')
44
+      if ($typeName == 'column_name')
45 45
       {
46 46
         if (!isset($this->columnTypes['column_name']))
47 47
         {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,15 +47,13 @@
 block discarded – undo
47 47
         {
48 48
           $this->columnTypes[$typeName] = $typeValue;
49 49
         }
50
-      }
51
-      else
50
+      } else
52 51
       {
53 52
         $format = '%s_%s';
54 53
         if (isset($typePrefix))
55 54
         {
56 55
           $this->columnTypes[sprintf($format, $typePrefix, $typeName)] = $typeValue;
57
-        }
58
-        else
56
+        } else
59 57
         {
60 58
           $this->columnTypes[$typeName] = $typeValue;
61 59
         }
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -8,71 +8,71 @@
 block discarded – undo
8 8
  */
9 9
 class ColumnTypes
10 10
 {
11
-  //--------------------------------------------------------------------------------------------------------------------
12
-  /**
13
-   * The metadata of the columns.
14
-   *
15
-   * @var array[]
16
-   */
17
-  private $columnTypes = [];
11
+    //--------------------------------------------------------------------------------------------------------------------
12
+    /**
13
+     * The metadata of the columns.
14
+     *
15
+     * @var array[]
16
+     */
17
+    private $columnTypes = [];
18 18
 
19
-  //--------------------------------------------------------------------------------------------------------------------
20
-  /**
21
-   * Object constructor.
22
-   *
23
-   * @param array[]     $columnTypes The metadata of the column.
24
-   * @param null|string $typePrefix  Prefix for column type name.
25
-   */
26
-  public function __construct($columnTypes, $typePrefix = null)
27
-  {
19
+    //--------------------------------------------------------------------------------------------------------------------
20
+    /**
21
+     * Object constructor.
22
+     *
23
+     * @param array[]     $columnTypes The metadata of the column.
24
+     * @param null|string $typePrefix  Prefix for column type name.
25
+     */
26
+    public function __construct($columnTypes, $typePrefix = null)
27
+    {
28 28
     $this->appendColumnTypes($columnTypes, $typePrefix);
29
-  }
29
+    }
30 30
 
31
-  //--------------------------------------------------------------------------------------------------------------------
32
-  /**
33
-   * Return array with all columns types.
34
-   *
35
-   * @param array[] $columnTypes The metadata of the column.
36
-   * @param string  $typePrefix  Prefix for column type name.
37
-   */
38
-  public function appendColumnTypes($columnTypes, $typePrefix = null)
39
-  {
31
+    //--------------------------------------------------------------------------------------------------------------------
32
+    /**
33
+     * Return array with all columns types.
34
+     *
35
+     * @param array[] $columnTypes The metadata of the column.
36
+     * @param string  $typePrefix  Prefix for column type name.
37
+     */
38
+    public function appendColumnTypes($columnTypes, $typePrefix = null)
39
+    {
40 40
     foreach ($columnTypes as $typeName => $typeValue)
41 41
     {
42
-      if ($typeName=='column_name')
43
-      {
42
+        if ($typeName=='column_name')
43
+        {
44 44
         if (!isset($this->columnTypes['column_name']))
45 45
         {
46
-          $this->columnTypes[$typeName] = $typeValue;
46
+            $this->columnTypes[$typeName] = $typeValue;
47
+        }
47 48
         }
48
-      }
49
-      else
50
-      {
49
+        else
50
+        {
51 51
         $format = '%s_%s';
52 52
         if (isset($typePrefix))
53 53
         {
54
-          $this->columnTypes[sprintf($format, $typePrefix, $typeName)] = $typeValue;
54
+            $this->columnTypes[sprintf($format, $typePrefix, $typeName)] = $typeValue;
55 55
         }
56 56
         else
57 57
         {
58
-          $this->columnTypes[$typeName] = $typeValue;
58
+            $this->columnTypes[$typeName] = $typeValue;
59
+        }
59 60
         }
60
-      }
61 61
     }
62
-  }
62
+    }
63 63
 
64
-  //--------------------------------------------------------------------------------------------------------------------
65
-  /**
66
-   * Get columns types.
67
-   *
68
-   * @return array[]
69
-   */
70
-  public function getTypes()
71
-  {
64
+    //--------------------------------------------------------------------------------------------------------------------
65
+    /**
66
+     * Get columns types.
67
+     *
68
+     * @return array[]
69
+     */
70
+    public function getTypes()
71
+    {
72 72
     return $this->columnTypes;
73
-  }
73
+    }
74 74
 
75
-  //--------------------------------------------------------------------------------------------------------------------
75
+    //--------------------------------------------------------------------------------------------------------------------
76 76
 }
77 77
 
78 78
 //----------------------------------------------------------------------------------------------------------------------
Please login to merge, or discard this patch.
src/MySql/Helper/TableHelper.php 3 patches
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -112,19 +112,16 @@  discard block
 block discarded – undo
112 112
           {
113 113
             $styledColumn['column_name']     = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
114 114
             $styledColumn['data_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['data_table_type']);
115
-          }
116
-          else if (!isset($column['data_table_type']) && isset($column['audit_table_type']))
115
+          } else if (!isset($column['data_table_type']) && isset($column['audit_table_type']))
117 116
           {
118 117
             $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['audit_table_type']);
119
-          }
120
-          else if (strcmp($column['data_table_type'], $column['audit_table_type']))
118
+          } else if (strcmp($column['data_table_type'], $column['audit_table_type']))
121 119
           {
122 120
             $styledColumn['column_name']      = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
123 121
             $styledColumn['data_table_type']  = sprintf('<mm_type>%s</>', $styledColumn['data_table_type']);
124 122
             $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['audit_table_type']);
125 123
           }
126
-        }
127
-        else
124
+        } else
128 125
         {
129 126
           // Highlighting for audit table column types and audit_columns in config file.
130 127
           $searchColumn = StaticDataLayer::searchInRowSet('column_name', $styledColumn['column_name'], $this->auditColumns);
@@ -135,12 +132,10 @@  discard block
 block discarded – undo
135 132
             {
136 133
               $styledColumn['column_name'] = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
137 134
               $styledColumn['config_type'] = sprintf('<mm_type>%s</>', $styledColumn['config_type']);
138
-            }
139
-            else if (!isset($configType) && isset($column['audit_table_type']))
135
+            } else if (!isset($configType) && isset($column['audit_table_type']))
140 136
             {
141 137
               $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']);
142
-            }
143
-            else if (strcmp($configType, $column['audit_table_type']))
138
+            } else if (strcmp($configType, $column['audit_table_type']))
144 139
             {
145 140
               $styledColumn['column_name']      = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
146 141
               $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']);
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -13,187 +13,187 @@
 block discarded – undo
13 13
  */
14 14
 class TableHelper
15 15
 {
16
-  //--------------------------------------------------------------------------------------------------------------------
17
-  /**
18
-   * Array with rows for table.
19
-   *
20
-   * @var \array[]
21
-   */
22
-  private $rows = [];
16
+    //--------------------------------------------------------------------------------------------------------------------
17
+    /**
18
+     * Array with rows for table.
19
+     *
20
+     * @var \array[]
21
+     */
22
+    private $rows = [];
23 23
 
24
-  /**
25
-   * Audit columns from config file.
26
-   *
27
-   * @var array
28
-   */
29
-  private $auditColumns;
24
+    /**
25
+     * Audit columns from config file.
26
+     *
27
+     * @var array
28
+     */
29
+    private $auditColumns;
30 30
 
31
-  /**
32
-   * Table options from audit schema.
33
-   *
34
-   * @var array
35
-   */
36
-  private $auditTableOptions;
31
+    /**
32
+     * Table options from audit schema.
33
+     *
34
+     * @var array
35
+     */
36
+    private $auditTableOptions;
37 37
 
38
-  /**
39
-   * Table options from data schema.
40
-   *
41
-   * @var array
42
-   */
43
-  private $dataTableOptions;
38
+    /**
39
+     * Table options from data schema.
40
+     *
41
+     * @var array
42
+     */
43
+    private $dataTableOptions;
44 44
 
45
-  /**
46
-   * Full option.
47
-   *
48
-   * @var bool
49
-   */
50
-  private $fullOption;
45
+    /**
46
+     * Full option.
47
+     *
48
+     * @var bool
49
+     */
50
+    private $fullOption;
51 51
 
52
-  /**
53
-   * Check existing separator.
54
-   *
55
-   * @var bool
56
-   */
57
-  private $existSeparator = false;
52
+    /**
53
+     * Check existing separator.
54
+     *
55
+     * @var bool
56
+     */
57
+    private $existSeparator = false;
58 58
 
59
-  //--------------------------------------------------------------------------------------------------------------------
60
-  /**
61
-   * Object constructor.
62
-   *
63
-   * @param string  $dataSchema      Data schema name.
64
-   * @param string  $auditSchema     Audit schema name.
65
-   * @param string  $tableName       The table name.
66
-   * @param array[] $theAuditColumns Audit columns from config file.
67
-   * @param bool    $fullOption      If set append table options to rows.
68
-   */
69
-  public function __construct($dataSchema, $auditSchema, $tableName, $theAuditColumns, $fullOption)
70
-  {
59
+    //--------------------------------------------------------------------------------------------------------------------
60
+    /**
61
+     * Object constructor.
62
+     *
63
+     * @param string  $dataSchema      Data schema name.
64
+     * @param string  $auditSchema     Audit schema name.
65
+     * @param string  $tableName       The table name.
66
+     * @param array[] $theAuditColumns Audit columns from config file.
67
+     * @param bool    $fullOption      If set append table options to rows.
68
+     */
69
+    public function __construct($dataSchema, $auditSchema, $tableName, $theAuditColumns, $fullOption)
70
+    {
71 71
     $this->auditColumns      = $theAuditColumns;
72 72
     $this->fullOption        = $fullOption;
73 73
     $this->auditTableOptions = DataLayer::getTableOptions($auditSchema, $tableName);
74 74
     $this->dataTableOptions  = DataLayer::getTableOptions($dataSchema, $tableName);
75
-  }
75
+    }
76 76
 
77
-  //--------------------------------------------------------------------------------------------------------------------
78
-  /**
79
-   * Append row with table option.
80
-   *
81
-   * @param string      $theOption The option.
82
-   * @param null|string $theName   Display name.
83
-   */
84
-  public function appendTableOption($theOption, $theName = null)
85
-  {
77
+    //--------------------------------------------------------------------------------------------------------------------
78
+    /**
79
+     * Append row with table option.
80
+     *
81
+     * @param string      $theOption The option.
82
+     * @param null|string $theName   Display name.
83
+     */
84
+    public function appendTableOption($theOption, $theName = null)
85
+    {
86 86
     if ($this->dataTableOptions[$theOption]!=$this->auditTableOptions[$theOption] || $this->fullOption)
87 87
     {
88
-      if (!$this->existSeparator)
89
-      {
88
+        if (!$this->existSeparator)
89
+        {
90 90
         $this->rows[]         = new TableSeparator();
91 91
         $this->existSeparator = true;
92
-      }
93
-      if ($theName===null)
94
-      {
92
+        }
93
+        if ($theName===null)
94
+        {
95 95
         $theName = $theOption;
96
-      }
97
-      $tableRow               = ['column_name'        => $theName,
98
-                                 'data_column_type'   => $this->dataTableOptions[$theOption],
99
-                                 'audit_column_type'  => $this->auditTableOptions[$theOption],
100
-                                 'config_column_type' => null];
101
-      $this->rows[$theOption] = RowHelper::createTableRow($tableRow);
96
+        }
97
+        $tableRow               = ['column_name'        => $theName,
98
+                                    'data_column_type'   => $this->dataTableOptions[$theOption],
99
+                                    'audit_column_type'  => $this->auditTableOptions[$theOption],
100
+                                    'config_column_type' => null];
101
+        $this->rows[$theOption] = RowHelper::createTableRow($tableRow);
102
+    }
102 103
     }
103
-  }
104 104
 
105
-  //--------------------------------------------------------------------------------------------------------------------
106
-  /**
107
-   * Appends rows.
108
-   *
109
-   * @param \array[] $theRows Rows array.
110
-   */
111
-  public function appendRows($theRows)
112
-  {
105
+    //--------------------------------------------------------------------------------------------------------------------
106
+    /**
107
+     * Appends rows.
108
+     *
109
+     * @param \array[] $theRows Rows array.
110
+     */
111
+    public function appendRows($theRows)
112
+    {
113 113
     /** @var ColumnTypes $row */
114 114
     foreach ($theRows as $row)
115 115
     {
116
-      RowHelper::appendRow($this->rows, $row);
116
+        RowHelper::appendRow($this->rows, $row);
117 117
     }
118 118
     $this->appendTableOption('engine');
119 119
     $this->appendTableOption('character_set_name', 'character set');
120 120
     $this->appendTableOption('table_collation', 'collation');
121
-  }
121
+    }
122 122
 
123
-  //--------------------------------------------------------------------------------------------------------------------
124
-  /**
125
-   * Add highlighting to columns.
126
-   */
127
-  public function addHighlighting()
128
-  {
123
+    //--------------------------------------------------------------------------------------------------------------------
124
+    /**
125
+     * Add highlighting to columns.
126
+     */
127
+    public function addHighlighting()
128
+    {
129 129
     $styledColumns = [];
130 130
     foreach ($this->rows as $column)
131 131
     {
132
-      $styledColumn = $column;
133
-      if (is_array($column))
134
-      {
132
+        $styledColumn = $column;
133
+        if (is_array($column))
134
+        {
135 135
         // Highlighting for data table column types and audit.
136 136
         if (!empty($column['data_table_type']))
137 137
         {
138
-          if (isset($column['data_table_type']) && !isset($column['audit_table_type']))
139
-          {
138
+            if (isset($column['data_table_type']) && !isset($column['audit_table_type']))
139
+            {
140 140
             $styledColumn['column_name']     = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
141 141
             $styledColumn['data_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['data_table_type']);
142
-          }
143
-          else if (!isset($column['data_table_type']) && isset($column['audit_table_type']))
144
-          {
142
+            }
143
+            else if (!isset($column['data_table_type']) && isset($column['audit_table_type']))
144
+            {
145 145
             $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['audit_table_type']);
146
-          }
147
-          else if (strcmp($column['data_table_type'], $column['audit_table_type']))
148
-          {
146
+            }
147
+            else if (strcmp($column['data_table_type'], $column['audit_table_type']))
148
+            {
149 149
             $styledColumn['column_name']      = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
150 150
             $styledColumn['data_table_type']  = sprintf('<mm_type>%s</>', $styledColumn['data_table_type']);
151 151
             $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['audit_table_type']);
152
-          }
152
+            }
153 153
         }
154 154
         else
155 155
         {
156
-          // Highlighting for audit table column types and audit_columns in config file.
157
-          $searchColumn = StaticDataLayer::searchInRowSet('column_name', $styledColumn['column_name'], $this->auditColumns);
158
-          if (isset($searchColumn))
159
-          {
156
+            // Highlighting for audit table column types and audit_columns in config file.
157
+            $searchColumn = StaticDataLayer::searchInRowSet('column_name', $styledColumn['column_name'], $this->auditColumns);
158
+            if (isset($searchColumn))
159
+            {
160 160
             $configType = $this->auditColumns[$searchColumn]['column_type'];
161 161
             if (isset($configType) && !isset($column['audit_table_type']))
162 162
             {
163
-              $styledColumn['column_name'] = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
164
-              $styledColumn['config_type'] = sprintf('<mm_type>%s</>', $styledColumn['config_type']);
163
+                $styledColumn['column_name'] = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
164
+                $styledColumn['config_type'] = sprintf('<mm_type>%s</>', $styledColumn['config_type']);
165 165
             }
166 166
             else if (!isset($configType) && isset($column['audit_table_type']))
167 167
             {
168
-              $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']);
168
+                $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']);
169 169
             }
170 170
             else if (strcmp($configType, $column['audit_table_type']))
171 171
             {
172
-              $styledColumn['column_name']      = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
173
-              $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']);
174
-              $styledColumn['config_type']      = sprintf('<mm_type>%s</>', $styledColumn['config_type']);
172
+                $styledColumn['column_name']      = sprintf('<mm_column>%s</>', $styledColumn['column_name']);
173
+                $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']);
174
+                $styledColumn['config_type']      = sprintf('<mm_type>%s</>', $styledColumn['config_type']);
175
+            }
175 176
             }
176
-          }
177 177
         }
178
-      }
179
-      $styledColumns[] = $styledColumn;
178
+        }
179
+        $styledColumns[] = $styledColumn;
180 180
     }
181 181
 
182 182
     $this->rows = $styledColumns;
183
-  }
183
+    }
184 184
 
185
-  //--------------------------------------------------------------------------------------------------------------------
186
-  /**
187
-   * Get rows.
188
-   *
189
-   * @return \array[]
190
-   */
191
-  public function getRows()
192
-  {
185
+    //--------------------------------------------------------------------------------------------------------------------
186
+    /**
187
+     * Get rows.
188
+     *
189
+     * @return \array[]
190
+     */
191
+    public function getRows()
192
+    {
193 193
     return $this->rows;
194
-  }
194
+    }
195 195
 
196
-  //--------------------------------------------------------------------------------------------------------------------
196
+    //--------------------------------------------------------------------------------------------------------------------
197 197
 }
198 198
 
199 199
 //----------------------------------------------------------------------------------------------------------------------
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,18 +83,18 @@
 block discarded – undo
83 83
    */
84 84
   public function appendTableOption($theOption, $theName = null)
85 85
   {
86
-    if ($this->dataTableOptions[$theOption]!=$this->auditTableOptions[$theOption] || $this->fullOption)
86
+    if ($this->dataTableOptions[$theOption] != $this->auditTableOptions[$theOption] || $this->fullOption)
87 87
     {
88 88
       if (!$this->existSeparator)
89 89
       {
90 90
         $this->rows[]         = new TableSeparator();
91 91
         $this->existSeparator = true;
92 92
       }
93
-      if ($theName===null)
93
+      if ($theName === null)
94 94
       {
95 95
         $theName = $theOption;
96 96
       }
97
-      $tableRow               = ['column_name'        => $theName,
97
+      $tableRow = ['column_name'        => $theName,
98 98
                                  'data_column_type'   => $this->dataTableOptions[$theOption],
99 99
                                  'audit_column_type'  => $this->auditTableOptions[$theOption],
100 100
                                  'config_column_type' => null];
Please login to merge, or discard this patch.
src/Command/DiffCommand.php 3 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -22,89 +22,89 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class DiffCommand extends AuditCommand
24 24
 {
25
-  //--------------------------------------------------------------------------------------------------------------------
26
-  /**
27
-   * Array with columns for each table.
28
-   * array [
29
-   *    table_name [
30
-   *            column [
31
-   *                    data table type,
32
-   *                    audit table type
33
-   *                    ],
34
-   *                      ...
35
-   *               ]
36
-   *       ]
37
-   *
38
-   * @var array[]
39
-   */
40
-  private $diffColumns;
25
+    //--------------------------------------------------------------------------------------------------------------------
26
+    /**
27
+     * Array with columns for each table.
28
+     * array [
29
+     *    table_name [
30
+     *            column [
31
+     *                    data table type,
32
+     *                    audit table type
33
+     *                    ],
34
+     *                      ...
35
+     *               ]
36
+     *       ]
37
+     *
38
+     * @var array[]
39
+     */
40
+    private $diffColumns;
41 41
 
42
-  /**
43
-   * If set all tables and columns are shown.
44
-   *
45
-   * @var boolean
46
-   */
47
-  private $full;
42
+    /**
43
+     * If set all tables and columns are shown.
44
+     *
45
+     * @var boolean
46
+     */
47
+    private $full;
48 48
 
49
-  //--------------------------------------------------------------------------------------------------------------------
50
-  /**
51
-   * Check full full and return array without new or obsolete columns if full not set.
52
-   *
53
-   * @param array[] $columns The metadata of the columns of a table.
54
-   *
55
-   * @return array[]
56
-   */
57
-  private static function removeMatchingColumns($columns)
58
-  {
49
+    //--------------------------------------------------------------------------------------------------------------------
50
+    /**
51
+     * Check full full and return array without new or obsolete columns if full not set.
52
+     *
53
+     * @param array[] $columns The metadata of the columns of a table.
54
+     *
55
+     * @return array[]
56
+     */
57
+    private static function removeMatchingColumns($columns)
58
+    {
59 59
     $cleaned = [];
60 60
     /** @var ColumnTypes $column */
61 61
     foreach ($columns as $column)
62 62
     {
63
-      $columnsArray = $column->getTypes();
64
-      if (!isset($columnsArray['data_column_type']))
65
-      {
63
+        $columnsArray = $column->getTypes();
64
+        if (!isset($columnsArray['data_column_type']))
65
+        {
66 66
         if ($columnsArray['audit_column_type']!=$columnsArray['config_column_type'])
67 67
         {
68
-          $cleaned[] = $column;
68
+            $cleaned[] = $column;
69
+        }
69 70
         }
70
-      }
71
-      elseif (!isset($columnsArray['config_column_type']))
72
-      {
71
+        elseif (!isset($columnsArray['config_column_type']))
72
+        {
73 73
         if (($columnsArray['audit_column_type']!=$columnsArray['data_column_type']) || ($columnsArray['audit_character_set_name']!=$columnsArray['data_character_set_name'] || $columnsArray['audit_collation_name']!=$columnsArray['data_collation_name']))
74 74
         {
75
-          $cleaned[] = $column;
75
+            $cleaned[] = $column;
76
+        }
76 77
         }
77
-      }
78
-      else
79
-      {
78
+        else
79
+        {
80 80
         if (($columnsArray['data_column_type']!=$columnsArray['audit_column_type'] && $columnsArray['audit_column_type']!=$columnsArray['config_column_type']) || ($columnsArray['audit_column_type']!=$columnsArray['config_column_type'] && !empty($columnsArray['config_column_type'])))
81 81
         {
82
-          $cleaned[] = $column;
82
+            $cleaned[] = $column;
83
+        }
83 84
         }
84
-      }
85 85
     }
86 86
 
87 87
     return $cleaned;
88
-  }
88
+    }
89 89
 
90
-  //--------------------------------------------------------------------------------------------------------------------
91
-  /**
92
-   * {@inheritdoc}
93
-   */
94
-  protected function configure()
95
-  {
90
+    //--------------------------------------------------------------------------------------------------------------------
91
+    /**
92
+     * {@inheritdoc}
93
+     */
94
+    protected function configure()
95
+    {
96 96
     $this->setName('diff')
97
-         ->setDescription('Compares data tables and audit tables')
98
-         ->addArgument('config file', InputArgument::OPTIONAL, 'The audit configuration file', 'etc/audit.json')
99
-         ->addOption('full', 'f', InputOption::VALUE_NONE, 'Show all columns');
100
-  }
97
+            ->setDescription('Compares data tables and audit tables')
98
+            ->addArgument('config file', InputArgument::OPTIONAL, 'The audit configuration file', 'etc/audit.json')
99
+            ->addOption('full', 'f', InputOption::VALUE_NONE, 'Show all columns');
100
+    }
101 101
 
102
-  //--------------------------------------------------------------------------------------------------------------------
103
-  /**
104
-   * {@inheritdoc}
105
-   */
106
-  protected function execute(InputInterface $input, OutputInterface $output)
107
-  {
102
+    //--------------------------------------------------------------------------------------------------------------------
103
+    /**
104
+     * {@inheritdoc}
105
+     */
106
+    protected function execute(InputInterface $input, OutputInterface $output)
107
+    {
108 108
     $this->io = new StratumStyle($input, $output);
109 109
     // Style for column names with miss matched column types.
110 110
     $style = new OutputFormatterStyle(null, 'red');
@@ -133,179 +133,179 @@  discard block
 block discarded – undo
133 133
 
134 134
     $this->getDiff();
135 135
     $this->printDiff($output);
136
-  }
136
+    }
137 137
 
138
-  //--------------------------------------------------------------------------------------------------------------------
139
-  /**
140
-   * Get the difference between data and audit tables.
141
-   *
142
-   * @param Columns $dataColumns  The table columns from data schema.
143
-   * @param Columns $auditColumns The table columns from audit schema.
144
-   *
145
-   * @return \array[]
146
-   */
147
-  private function createDiffArray($dataColumns, $auditColumns)
148
-  {
138
+    //--------------------------------------------------------------------------------------------------------------------
139
+    /**
140
+     * Get the difference between data and audit tables.
141
+     *
142
+     * @param Columns $dataColumns  The table columns from data schema.
143
+     * @param Columns $auditColumns The table columns from audit schema.
144
+     *
145
+     * @return \array[]
146
+     */
147
+    private function createDiffArray($dataColumns, $auditColumns)
148
+    {
149 149
     $diff = [];
150 150
 
151 151
     foreach ($this->config['audit_columns'] as $column)
152 152
     {
153
-      $columnTypes                  = new ColumnTypes($column, 'config');
154
-      $diff[$column['column_name']] = $columnTypes;
153
+        $columnTypes                  = new ColumnTypes($column, 'config');
154
+        $diff[$column['column_name']] = $columnTypes;
155 155
     }
156 156
 
157 157
     foreach ($auditColumns->getColumns() as $column)
158 158
     {
159
-      if (isset($diff[$column['column_name']]))
160
-      {
159
+        if (isset($diff[$column['column_name']]))
160
+        {
161 161
         $diff[$column['column_name']]->appendColumnTypes($column, 'audit');
162
-      }
163
-      else
164
-      {
162
+        }
163
+        else
164
+        {
165 165
         $columnTypes                  = new ColumnTypes($column, 'audit');
166 166
         $diff[$column['column_name']] = $columnTypes;
167
-      }
167
+        }
168 168
     }
169 169
 
170 170
     foreach ($dataColumns->getColumns() as $column)
171 171
     {
172
-      if (isset($diff[$column['column_name']]))
173
-      {
172
+        if (isset($diff[$column['column_name']]))
173
+        {
174 174
         $diff[$column['column_name']]->appendColumnTypes($column, 'data');
175
-      }
176
-      else
177
-      {
175
+        }
176
+        else
177
+        {
178 178
         $columnTypes                  = new ColumnTypes($column, 'data');
179 179
         $diff[$column['column_name']] = $columnTypes;
180
-      }
180
+        }
181 181
     }
182 182
 
183 183
     return $diff;
184
-  }
184
+    }
185 185
 
186
-  //--------------------------------------------------------------------------------------------------------------------
187
-  /**
188
-   * Computes the difference between data and audit tables.
189
-   */
190
-  private function getDiff()
191
-  {
186
+    //--------------------------------------------------------------------------------------------------------------------
187
+    /**
188
+     * Computes the difference between data and audit tables.
189
+     */
190
+    private function getDiff()
191
+    {
192 192
     foreach ($this->dataSchemaTables as $table)
193 193
     {
194
-      if ($this->config['tables'][$table['table_name']]['audit'])
195
-      {
194
+        if ($this->config['tables'][$table['table_name']]['audit'])
195
+        {
196 196
         $res = StaticDataLayer::searchInRowSet('table_name', $table['table_name'], $this->auditSchemaTables);
197 197
         if (isset($res))
198 198
         {
199
-          $dataColumns  = new Columns(DataLayer::getTableColumns($this->config['database']['data_schema'], $table['table_name']));
200
-          $auditColumns = DataLayer::getTableColumns($this->config['database']['audit_schema'], $table['table_name']);
201
-          $auditColumns = $this->addNotNull($auditColumns);
202
-          $auditColumns = new Columns($auditColumns);
199
+            $dataColumns  = new Columns(DataLayer::getTableColumns($this->config['database']['data_schema'], $table['table_name']));
200
+            $auditColumns = DataLayer::getTableColumns($this->config['database']['audit_schema'], $table['table_name']);
201
+            $auditColumns = $this->addNotNull($auditColumns);
202
+            $auditColumns = new Columns($auditColumns);
203 203
 
204
-          $this->diffColumns[$table['table_name']] = $this->createDiffArray($dataColumns, $auditColumns);
204
+            $this->diffColumns[$table['table_name']] = $this->createDiffArray($dataColumns, $auditColumns);
205
+        }
205 206
         }
206
-      }
207 207
     }
208
-  }
208
+    }
209 209
 
210
-  //--------------------------------------------------------------------------------------------------------------------
211
-  /**
212
-   * Add not null to audit columns if it not nullable.
213
-   *
214
-   * @param array $theColumns Audit columns.
215
-   *
216
-   * @return array
217
-   */
218
-  private function addNotNull($theColumns)
219
-  {
210
+    //--------------------------------------------------------------------------------------------------------------------
211
+    /**
212
+     * Add not null to audit columns if it not nullable.
213
+     *
214
+     * @param array $theColumns Audit columns.
215
+     *
216
+     * @return array
217
+     */
218
+    private function addNotNull($theColumns)
219
+    {
220 220
     $modifiedColumns = [];
221 221
     foreach ($theColumns as $column)
222 222
     {
223
-      $modifiedColumn = $column;
224
-      $auditColumn    = StaticDataLayer::searchInRowSet('column_name', $modifiedColumn['column_name'], $this->config['audit_columns']);
225
-      if (isset($auditColumn))
226
-      {
223
+        $modifiedColumn = $column;
224
+        $auditColumn    = StaticDataLayer::searchInRowSet('column_name', $modifiedColumn['column_name'], $this->config['audit_columns']);
225
+        if (isset($auditColumn))
226
+        {
227 227
         if ($modifiedColumn['is_nullable']==='NO')
228 228
         {
229
-          $modifiedColumn['column_type'] = sprintf('%s not null', $modifiedColumn['column_type']);
229
+            $modifiedColumn['column_type'] = sprintf('%s not null', $modifiedColumn['column_type']);
230 230
         }
231
-      }
232
-      $modifiedColumns[] = $modifiedColumn;
231
+        }
232
+        $modifiedColumns[] = $modifiedColumn;
233 233
     }
234 234
 
235 235
     return $modifiedColumns;
236
-  }
236
+    }
237 237
 
238
-  //--------------------------------------------------------------------------------------------------------------------
239
-  /**
240
-   * Writes the difference between the audit tables and metadata tables to the output.
241
-   *
242
-   * @param OutputInterface $output The output.
243
-   */
244
-  private function diffTables($output)
245
-  {
238
+    //--------------------------------------------------------------------------------------------------------------------
239
+    /**
240
+     * Writes the difference between the audit tables and metadata tables to the output.
241
+     *
242
+     * @param OutputInterface $output The output.
243
+     */
244
+    private function diffTables($output)
245
+    {
246 246
     foreach ($this->config['tables'] as $tableName => $table)
247 247
     {
248
-      $res = StaticDataLayer::searchInRowSet('table_name', $tableName, $this->auditSchemaTables);
249
-      if ($table['audit'] && !isset($res))
250
-      {
248
+        $res = StaticDataLayer::searchInRowSet('table_name', $tableName, $this->auditSchemaTables);
249
+        if ($table['audit'] && !isset($res))
250
+        {
251 251
         $output->writeln(sprintf('<miss_table>%s</>', $tableName));
252
-      }
253
-      else if (!$table['audit'] && isset($res))
254
-      {
252
+        }
253
+        else if (!$table['audit'] && isset($res))
254
+        {
255 255
         $output->writeln(sprintf('<obsolete_table>%s</>', $tableName));
256
-      }
256
+        }
257
+    }
257 258
     }
258
-  }
259 259
 
260
-  //--------------------------------------------------------------------------------------------------------------------
261
-  /**
262
-   * Writes the difference between the audit and data tables to the output.
263
-   *
264
-   * @param OutputInterface $output The output.
265
-   */
266
-  private function printDiff($output)
267
-  {
260
+    //--------------------------------------------------------------------------------------------------------------------
261
+    /**
262
+     * Writes the difference between the audit and data tables to the output.
263
+     *
264
+     * @param OutputInterface $output The output.
265
+     */
266
+    private function printDiff($output)
267
+    {
268 268
     $first = true;
269 269
     if (isset($this->diffColumns))
270 270
     {
271
-      foreach ($this->diffColumns as $tableName => $columns)
272
-      {
271
+        foreach ($this->diffColumns as $tableName => $columns)
272
+        {
273 273
         // Remove matching columns unless the full option is used.
274 274
         if (!$this->full)
275 275
         {
276
-          $columns = self::removeMatchingColumns($columns);
276
+            $columns = self::removeMatchingColumns($columns);
277 277
         }
278 278
 
279 279
         if (!empty($columns))
280 280
         {
281
-          // Add an empty line between tables.
282
-          if ($first)
283
-          {
281
+            // Add an empty line between tables.
282
+            if ($first)
283
+            {
284 284
             $first = false;
285
-          }
286
-          else
287
-          {
285
+            }
286
+            else
287
+            {
288 288
             $output->writeln('');
289
-          }
289
+            }
290 290
 
291
-          // Write table name.
292
-          $output->writeln($tableName);
291
+            // Write table name.
292
+            $output->writeln($tableName);
293 293
 
294
-          // Write table with columns.
295
-          $rows = new TableHelper($this->config['database']['data_schema'], $this->config['database']['audit_schema'], $tableName, $this->config['audit_columns'], $this->full);
296
-          $rows->appendRows($columns);
297
-          $rows->addHighlighting();
298
-          $table = new Table($output);
299
-          $table->setHeaders(['column', 'data table', 'audit table', 'config'])
294
+            // Write table with columns.
295
+            $rows = new TableHelper($this->config['database']['data_schema'], $this->config['database']['audit_schema'], $tableName, $this->config['audit_columns'], $this->full);
296
+            $rows->appendRows($columns);
297
+            $rows->addHighlighting();
298
+            $table = new Table($output);
299
+            $table->setHeaders(['column', 'data table', 'audit table', 'config'])
300 300
                 ->setRows($rows->getRows());
301
-          $table->render();
301
+            $table->render();
302
+        }
302 303
         }
303
-      }
304 304
     }
305 305
     $this->diffTables($output);
306
-  }
306
+    }
307 307
 
308
-  //--------------------------------------------------------------------------------------------------------------------
308
+    //--------------------------------------------------------------------------------------------------------------------
309 309
 }
310 310
 
311 311
 //----------------------------------------------------------------------------------------------------------------------
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,21 +63,21 @@  discard block
 block discarded – undo
63 63
       $columnsArray = $column->getTypes();
64 64
       if (!isset($columnsArray['data_column_type']))
65 65
       {
66
-        if ($columnsArray['audit_column_type']!=$columnsArray['config_column_type'])
66
+        if ($columnsArray['audit_column_type'] != $columnsArray['config_column_type'])
67 67
         {
68 68
           $cleaned[] = $column;
69 69
         }
70 70
       }
71 71
       elseif (!isset($columnsArray['config_column_type']))
72 72
       {
73
-        if (($columnsArray['audit_column_type']!=$columnsArray['data_column_type']) || ($columnsArray['audit_character_set_name']!=$columnsArray['data_character_set_name'] || $columnsArray['audit_collation_name']!=$columnsArray['data_collation_name']))
73
+        if (($columnsArray['audit_column_type'] != $columnsArray['data_column_type']) || ($columnsArray['audit_character_set_name'] != $columnsArray['data_character_set_name'] || $columnsArray['audit_collation_name'] != $columnsArray['data_collation_name']))
74 74
         {
75 75
           $cleaned[] = $column;
76 76
         }
77 77
       }
78 78
       else
79 79
       {
80
-        if (($columnsArray['data_column_type']!=$columnsArray['audit_column_type'] && $columnsArray['audit_column_type']!=$columnsArray['config_column_type']) || ($columnsArray['audit_column_type']!=$columnsArray['config_column_type'] && !empty($columnsArray['config_column_type'])))
80
+        if (($columnsArray['data_column_type'] != $columnsArray['audit_column_type'] && $columnsArray['audit_column_type'] != $columnsArray['config_column_type']) || ($columnsArray['audit_column_type'] != $columnsArray['config_column_type'] && !empty($columnsArray['config_column_type'])))
81 81
         {
82 82
           $cleaned[] = $column;
83 83
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
       $auditColumn    = StaticDataLayer::searchInRowSet('column_name', $modifiedColumn['column_name'], $this->config['audit_columns']);
225 225
       if (isset($auditColumn))
226 226
       {
227
-        if ($modifiedColumn['is_nullable']==='NO')
227
+        if ($modifiedColumn['is_nullable'] === 'NO')
228 228
         {
229 229
           $modifiedColumn['column_type'] = sprintf('%s not null', $modifiedColumn['column_type']);
230 230
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -67,15 +67,13 @@  discard block
 block discarded – undo
67 67
         {
68 68
           $cleaned[] = $column;
69 69
         }
70
-      }
71
-      elseif (!isset($columnsArray['config_column_type']))
70
+      } elseif (!isset($columnsArray['config_column_type']))
72 71
       {
73 72
         if (($columnsArray['audit_column_type']!=$columnsArray['data_column_type']) || ($columnsArray['audit_character_set_name']!=$columnsArray['data_character_set_name'] || $columnsArray['audit_collation_name']!=$columnsArray['data_collation_name']))
74 73
         {
75 74
           $cleaned[] = $column;
76 75
         }
77
-      }
78
-      else
76
+      } else
79 77
       {
80 78
         if (($columnsArray['data_column_type']!=$columnsArray['audit_column_type'] && $columnsArray['audit_column_type']!=$columnsArray['config_column_type']) || ($columnsArray['audit_column_type']!=$columnsArray['config_column_type'] && !empty($columnsArray['config_column_type'])))
81 79
         {
@@ -159,8 +157,7 @@  discard block
 block discarded – undo
159 157
       if (isset($diff[$column['column_name']]))
160 158
       {
161 159
         $diff[$column['column_name']]->appendColumnTypes($column, 'audit');
162
-      }
163
-      else
160
+      } else
164 161
       {
165 162
         $columnTypes                  = new ColumnTypes($column, 'audit');
166 163
         $diff[$column['column_name']] = $columnTypes;
@@ -172,8 +169,7 @@  discard block
 block discarded – undo
172 169
       if (isset($diff[$column['column_name']]))
173 170
       {
174 171
         $diff[$column['column_name']]->appendColumnTypes($column, 'data');
175
-      }
176
-      else
172
+      } else
177 173
       {
178 174
         $columnTypes                  = new ColumnTypes($column, 'data');
179 175
         $diff[$column['column_name']] = $columnTypes;
@@ -249,8 +245,7 @@  discard block
 block discarded – undo
249 245
       if ($table['audit'] && !isset($res))
250 246
       {
251 247
         $output->writeln(sprintf('<miss_table>%s</>', $tableName));
252
-      }
253
-      else if (!$table['audit'] && isset($res))
248
+      } else if (!$table['audit'] && isset($res))
254 249
       {
255 250
         $output->writeln(sprintf('<obsolete_table>%s</>', $tableName));
256 251
       }
@@ -282,8 +277,7 @@  discard block
 block discarded – undo
282 277
           if ($first)
283 278
           {
284 279
             $first = false;
285
-          }
286
-          else
280
+          } else
287 281
           {
288 282
             $output->writeln('');
289 283
           }
Please login to merge, or discard this patch.
src/MySql/Helper/RowHelper.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class RowHelper
13 13
 {
14
-  //--------------------------------------------------------------------------------------------------------------------
15
-  /**
16
-   * Create table row.
17
-   *
18
-   * @param array[] $theRow Data for table row.
19
-   *
20
-   * @return array[]
21
-   */
22
-  public static function createColumnOptionsRow($theRow)
23
-  {
14
+    //--------------------------------------------------------------------------------------------------------------------
15
+    /**
16
+     * Create table row.
17
+     *
18
+     * @param array[] $theRow Data for table row.
19
+     *
20
+     * @return array[]
21
+     */
22
+    public static function createColumnOptionsRow($theRow)
23
+    {
24 24
     $dataCharsetName   = isset($theRow['data_character_set_name']) ? $theRow['data_character_set_name'] : null;
25 25
     $dataCollationName = isset($theRow['data_collation_name']) ? $theRow['data_collation_name'] : null;
26 26
 
@@ -29,97 +29,97 @@  discard block
 block discarded – undo
29 29
 
30 30
 
31 31
     $tableRow = ['column_name'      => null,
32
-                 'data_table_type'  => self::styledOptionsRow($dataCharsetName, $dataCollationName),
33
-                 'audit_table_type' => self::styledOptionsRow($auditCharsetName, $auditCollationName),
34
-                 'config_type'      => null];
32
+                    'data_table_type'  => self::styledOptionsRow($dataCharsetName, $dataCollationName),
33
+                    'audit_table_type' => self::styledOptionsRow($auditCharsetName, $auditCollationName),
34
+                    'config_type'      => null];
35 35
 
36 36
     return $tableRow;
37
-  }
38
-
39
-  //--------------------------------------------------------------------------------------------------------------------
40
-  /**
41
-   * Create table row.
42
-   *
43
-   * @param $theCharacterSetName
44
-   * @param $theCollationName
45
-   *
46
-   * @return string
47
-   */
48
-  public static function styledOptionsRow($theCharacterSetName, $theCollationName)
49
-  {
37
+    }
38
+
39
+    //--------------------------------------------------------------------------------------------------------------------
40
+    /**
41
+     * Create table row.
42
+     *
43
+     * @param $theCharacterSetName
44
+     * @param $theCollationName
45
+     *
46
+     * @return string
47
+     */
48
+    public static function styledOptionsRow($theCharacterSetName, $theCollationName)
49
+    {
50 50
     $charsetName   = isset($theCharacterSetName) ? '['.$theCharacterSetName.']' : null;
51 51
     $collationName = isset($theCollationName) ? '['.$theCollationName.']' : null;
52 52
 
53 53
     return trim(sprintf('%s %s', $charsetName, $collationName));
54
-  }
55
-
56
-  //--------------------------------------------------------------------------------------------------------------------
57
-  /**
58
-   * Create table row.
59
-   *
60
-   * @param array[] $theRow Data for table row.
61
-   *
62
-   * @return array[]
63
-   */
64
-  public static function createTableRow($theRow)
65
-  {
54
+    }
55
+
56
+    //--------------------------------------------------------------------------------------------------------------------
57
+    /**
58
+     * Create table row.
59
+     *
60
+     * @param array[] $theRow Data for table row.
61
+     *
62
+     * @return array[]
63
+     */
64
+    public static function createTableRow($theRow)
65
+    {
66 66
     $tableRow = ['column_name'      => isset($theRow['column_name']) ? $theRow['column_name'] : null,
67
-                 'data_table_type'  => isset($theRow['data_column_type']) ? $theRow['data_column_type'] : null,
68
-                 'audit_table_type' => isset($theRow['audit_column_type']) ? $theRow['audit_column_type'] : null,
69
-                 'config_type'      => isset($theRow['config_column_type']) ? $theRow['config_column_type'] : null];
67
+                    'data_table_type'  => isset($theRow['data_column_type']) ? $theRow['data_column_type'] : null,
68
+                    'audit_table_type' => isset($theRow['audit_column_type']) ? $theRow['audit_column_type'] : null,
69
+                    'config_type'      => isset($theRow['config_column_type']) ? $theRow['config_column_type'] : null];
70 70
 
71 71
     return $tableRow;
72
-  }
73
-
74
-  //--------------------------------------------------------------------------------------------------------------------
75
-  /**
76
-   * Check isset options(collation, character set name) from row.
77
-   *
78
-   * @param array[] $theRow Row for append.
79
-   *
80
-   * @return bool
81
-   */
82
-  private static function checkOptions($theRow)
83
-  {
72
+    }
73
+
74
+    //--------------------------------------------------------------------------------------------------------------------
75
+    /**
76
+     * Check isset options(collation, character set name) from row.
77
+     *
78
+     * @param array[] $theRow Row for append.
79
+     *
80
+     * @return bool
81
+     */
82
+    private static function checkOptions($theRow)
83
+    {
84 84
     if (isset($theRow['audit_character_set_name']))
85 85
     {
86
-      return true;
86
+        return true;
87 87
     }
88 88
     if (isset($theRow['data_character_set_name']))
89 89
     {
90
-      return true;
90
+        return true;
91 91
     }
92 92
     if (isset($theRow['audit_collation_name']))
93 93
     {
94
-      return true;
94
+        return true;
95 95
     }
96 96
     if (isset($theRow['data_collation_name']))
97 97
     {
98
-      return true;
98
+        return true;
99 99
     }
100 100
 
101 101
     return false;
102
-  }
103
-
104
-  //--------------------------------------------------------------------------------------------------------------------
105
-  /**
106
-   * Append a row.
107
-   *
108
-   * @param \array[]    $theExistRows Exist rows array for appending.
109
-   * @param ColumnTypes $theRow       Row for append.
110
-   */
111
-  public static function appendRow(&$theExistRows, $theRow)
112
-  {
102
+    }
103
+
104
+    //--------------------------------------------------------------------------------------------------------------------
105
+    /**
106
+     * Append a row.
107
+     *
108
+     * @param \array[]    $theExistRows Exist rows array for appending.
109
+     * @param ColumnTypes $theRow       Row for append.
110
+     */
111
+    public static function appendRow(&$theExistRows, $theRow)
112
+    {
113 113
     $theRow         = $theRow->getTypes();
114 114
     $theExistRows[] = self::createTableRow($theRow);
115 115
     if (self::checkOptions($theRow))
116 116
     {
117
-      $theRow         = self::createColumnOptionsRow($theRow);
118
-      $theExistRows[] = $theRow;
117
+        $theRow         = self::createColumnOptionsRow($theRow);
118
+        $theExistRows[] = $theRow;
119
+    }
119 120
     }
120
-  }
121 121
 
122
-  //--------------------------------------------------------------------------------------------------------------------
122
+    //--------------------------------------------------------------------------------------------------------------------
123 123
 }
124 124
 
125 125
 //----------------------------------------------------------------------------------------------------------------------
Please login to merge, or discard this patch.