Test Setup Failed
Push — master ( 7d63a7...ae062b )
by Php Easy Api
04:30
created
src/resta/Database/Migration/Src/SchemaCapsule.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * @param $file
38 38
      * @param $table
39 39
      */
40
-    public function __construct($config,$file,$table)
40
+    public function __construct($config, $file, $table)
41 41
     {
42 42
         $this->config                       = $config;
43 43
         $this->file                         = $file;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function alter(callable $callback)
54 54
     {
55
-        return $this->callbackWizardInstance(__FUNCTION__,$callback);
55
+        return $this->callbackWizardInstance(__FUNCTION__, $callback);
56 56
     }
57 57
 
58 58
     /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function create(callable $callback)
63 63
     {
64
-        return $this->callbackWizardInstance(__FUNCTION__,$callback);
64
+        return $this->callbackWizardInstance(__FUNCTION__, $callback);
65 65
     }
66 66
 
67 67
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     private function checkErrors($wizard)
71 71
     {
72 72
         $alterType = $wizard->getAlterType();
73
-        if(count($wizard->getNames())!==count($wizard->getTypes()) && (isset($alterType['group'])) && $alterType['group']!=='dropColumn'){
73
+        if (count($wizard->getNames())!==count($wizard->getTypes()) && (isset($alterType['group'])) && $alterType['group']!=='dropColumn') {
74 74
             $wizard->setError('name and types are not equal');
75 75
         }
76 76
     }
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
      * @param $method
107 107
      * @return string
108 108
      */
109
-    private function callbackWizardInstance($method,callable $callback)
109
+    private function callbackWizardInstance($method, callable $callback)
110 110
     {
111 111
         $wizardInstance = $this->getWizardInstance($method);
112 112
 
113
-        $callbackReturn = call_user_func_array($callback,[$wizardInstance]);
113
+        $callbackReturn = call_user_func_array($callback, [$wizardInstance]);
114 114
 
115 115
         $this->checkErrors($wizardInstance);
116 116
 
Please login to merge, or discard this patch.
Database/Migration/Src/GrammarStructure/Mysql/Wizard/WizardAlterGroup.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     private function getWizardAlterInstance($group)
48 48
     {
49
-        $this->setAlterType('group',$group);
49
+        $this->setAlterType('group', $group);
50 50
 
51 51
         return new WizardAlter($this);
52 52
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     private function dropWizardAlterInstance($group)
59 59
     {
60
-        $this->setAlterType('group',$group);
60
+        $this->setAlterType('group', $group);
61 61
 
62 62
         return $this;
63 63
     }
Please login to merge, or discard this patch.
src/resta/Database/Migration/Src/GrammarStructure/Mysql/Wizard/Wizard.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
     public function name($name)
132 132
     {
133 133
         if(in_array($name,$this->name)){
134
-           $this->setError('You have written the '.$name.' name more than 1.');
134
+            $this->setError('You have written the '.$name.' name more than 1.');
135 135
         }
136 136
 
137 137
         $this->name[] = $name;
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     /**
26 26
      * @var array
27 27
      */
28
-    protected $auto_increment=array();
28
+    protected $auto_increment = array();
29 29
 
30 30
     /**
31 31
      * @var $collation
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
     /**
41 41
      * @var array $primaryKey
42 42
      */
43
-    protected $primaryKey=array();
43
+    protected $primaryKey = array();
44 44
 
45 45
     /**
46 46
      * @var array $references
47 47
      */
48
-    protected $references=array();
48
+    protected $references = array();
49 49
 
50 50
     /**
51 51
      * @var $schemaType
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
     /**
61 61
      * @var $name array
62 62
      */
63
-    protected $name=array();
63
+    protected $name = array();
64 64
 
65 65
     /**
66 66
      * @var array $nullable
67 67
      */
68
-    protected $nullable=array();
68
+    protected $nullable = array();
69 69
 
70 70
     /**
71 71
      * @var array $types
72 72
      */
73
-    protected $types=array();
73
+    protected $types = array();
74 74
 
75 75
     /**
76 76
      * @var $engine
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
     /**
81 81
      * @var $default array
82 82
      */
83
-    protected $default=array();
83
+    protected $default = array();
84 84
 
85 85
     /**
86 86
      * @var array $index
87 87
      */
88
-    protected $index=array();
88
+    protected $index = array();
89 89
 
90 90
     /**
91 91
      * @var array $unique
92 92
      */
93
-    protected $unique=array();
93
+    protected $unique = array();
94 94
 
95 95
     /**
96 96
      * @var $table
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function auto_increment()
104 104
     {
105
-        if(count($this->auto_increment)==0){
105
+        if (count($this->auto_increment)==0) {
106 106
 
107
-            if($this->getLastName()===false){
108
-                $this->name[]='id';
109
-                $this->setTypes('int',14);
107
+            if ($this->getLastName()===false) {
108
+                $this->name[] = 'id';
109
+                $this->setTypes('int', 14);
110 110
             }
111
-            $this->auto_increment[$this->getLastName()]=true;
111
+            $this->auto_increment[$this->getLastName()] = true;
112 112
             $this->primaryKey();
113 113
         }
114 114
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function comment($value)
121 121
     {
122
-        $this->comment[$this->getLastName()]=$value;
122
+        $this->comment[$this->getLastName()] = $value;
123 123
 
124 124
         return $this;
125 125
     }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function name($name)
132 132
     {
133
-        if(in_array($name,$this->name)){
133
+        if (in_array($name, $this->name)) {
134 134
            $this->setError('You have written the '.$name.' name more than 1.');
135 135
         }
136 136
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function default($value)
148 148
     {
149
-        $this->default[$this->getLastName()]=$value;
149
+        $this->default[$this->getLastName()] = $value;
150 150
 
151 151
         return $this;
152 152
     }
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
      * @param bool $table
157 157
      * @return $this
158 158
      */
159
-    public function collation($value,$table=false)
159
+    public function collation($value, $table = false)
160 160
     {
161
-        if($table===false)
161
+        if ($table===false)
162 162
         {
163
-            $this->collation[$this->getLastName()]=$value;
163
+            $this->collation[$this->getLastName()] = $value;
164 164
         }
165
-        else{
166
-            $this->collation['table']=$value;
165
+        else {
166
+            $this->collation['table'] = $value;
167 167
         }
168 168
 
169 169
         return $this;
@@ -175,17 +175,17 @@  discard block
 block discarded – undo
175 175
      * @param bool $key
176 176
      * @return $this|WizardContract
177 177
      */
178
-    public function index($name=null,$value=null,$key=false)
178
+    public function index($name = null, $value = null, $key = false)
179 179
     {
180 180
         $name   = ($name===null) ? $this->getLastName() : $name;
181 181
         $value  = ($value===null) ? $name : $value;
182 182
 
183
-        if($key===false){
184
-            $this->index[$this->getLastName()]=['name'=>$name,'value'=>$value];
183
+        if ($key===false) {
184
+            $this->index[$this->getLastName()] = ['name'=>$name, 'value'=>$value];
185 185
         }
186 186
 
187
-        if($key===true){
188
-            $this->index['indexes'][]=['name'=>$name,'value'=>$value];
187
+        if ($key===true) {
188
+            $this->index['indexes'][] = ['name'=>$name, 'value'=>$value];
189 189
         }
190 190
 
191 191
         return $this;
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
      * @param bool $null
196 196
      * @return $this
197 197
      */
198
-    public function nullable($null=true)
198
+    public function nullable($null = true)
199 199
     {
200
-        $this->nullable[$this->getLastName()]=$null;
200
+        $this->nullable[$this->getLastName()] = $null;
201 201
 
202 202
         return $this;
203 203
     }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function primaryKey()
209 209
     {
210
-        $this->primaryKey[$this->getLastName()]=true;
210
+        $this->primaryKey[$this->getLastName()] = true;
211 211
 
212 212
         return $this;
213 213
     }
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
      * @param null $value
226 226
      * @return $this|mixed
227 227
      */
228
-    public function unique($name=null,$value=null)
228
+    public function unique($name = null, $value = null)
229 229
     {
230 230
         $name   = ($name===null) ? $this->getLastName() : $name;
231 231
         $value  = ($value===null) ? $name : $value;
232 232
 
233
-        $this->unique[$this->getLastName()]=['name'=>$name,'value'=>$value];
233
+        $this->unique[$this->getLastName()] = ['name'=>$name, 'value'=>$value];
234 234
 
235 235
         return $this;
236 236
     }
Please login to merge, or discard this patch.
src/resta/Database/Migration/Src/GrammarStructure/Mysql/QuerySyntax.php 2 patches
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
      */
33 33
     private function addColumn($alterType)
34 34
     {
35
-        if(isset($alterType['place'])){
35
+        if (isset($alterType['place'])) {
36 36
 
37 37
 
38
-            foreach ($alterType['place'] as $placeKey=>$placeValue){
39
-                $placeList=$placeKey .' '.$placeValue.'';
38
+            foreach ($alterType['place'] as $placeKey=>$placeValue) {
39
+                $placeList = $placeKey.' '.$placeValue.'';
40 40
             }
41 41
 
42
-            $syntax = implode("",$this->syntax);
42
+            $syntax = implode("", $this->syntax);
43 43
 
44 44
             $alterSytanx = 'ALTER TABLE '.$this->table.' ADD COLUMN '.$syntax.' '.$placeList;
45 45
 
46
-            $query=$this->schema->getConnection()->setQueryBasic($alterSytanx);
46
+            $query = $this->schema->getConnection()->setQueryBasic($alterSytanx);
47 47
 
48
-            if(count($this->alterExtras)){
49
-                foreach($this->alterExtras as $extra){
48
+            if (count($this->alterExtras)) {
49
+                foreach ($this->alterExtras as $extra) {
50 50
 
51 51
                     $extraSyntax = 'ALTER TABLE '.$this->table.' '.$extra.'';
52 52
 
53
-                    $query=$this->schema->getConnection()->setQueryBasic($extraSyntax);
53
+                    $query = $this->schema->getConnection()->setQueryBasic($extraSyntax);
54 54
                 }
55 55
             }
56 56
 
@@ -74,40 +74,40 @@  discard block
 block discarded – undo
74 74
      */
75 75
     private function change($alterType)
76 76
     {
77
-        if(isset($alterType['place'])){
77
+        if (isset($alterType['place'])) {
78 78
 
79
-            foreach ($alterType['place'] as $placeKey=>$placeValue){
80
-                $placeList=$placeKey .' '.$placeValue.'';
79
+            foreach ($alterType['place'] as $placeKey=>$placeValue) {
80
+                $placeList = $placeKey.' '.$placeValue.'';
81 81
             }
82 82
 
83
-            $syntax = implode("",$this->syntax);
83
+            $syntax = implode("", $this->syntax);
84 84
 
85 85
             $columns = $this->schema->getConnection()->showColumnsFrom($this->table);
86 86
 
87
-            foreach ($columns as $columnKey=>$columnData){
88
-                if($columnData['Field']==$placeValue){
87
+            foreach ($columns as $columnKey=>$columnData) {
88
+                if ($columnData['Field']==$placeValue) {
89 89
                     $changeAbleField = $columns[$columnKey+1]['Field'];
90 90
                 }
91 91
             }
92 92
 
93
-            $syntaxList = explode(' ',$syntax);
93
+            $syntaxList = explode(' ', $syntax);
94 94
 
95
-            if(current($syntaxList)!==$changeAbleField){
96
-                $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).'  '.implode(' ',array_splice($syntaxList,1)).' '.$placeList;
95
+            if (current($syntaxList)!==$changeAbleField) {
96
+                $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).'  '.implode(' ', array_splice($syntaxList, 1)).' '.$placeList;
97 97
             }
98
-            else{
98
+            else {
99 99
                 $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList;
100 100
             }
101 101
 
102 102
 
103
-            $query=$this->schema->getConnection()->setQueryBasic($alterSytanx);
103
+            $query = $this->schema->getConnection()->setQueryBasic($alterSytanx);
104 104
 
105
-            if(count($this->alterExtras)){
106
-                foreach($this->alterExtras as $extra){
105
+            if (count($this->alterExtras)) {
106
+                foreach ($this->alterExtras as $extra) {
107 107
 
108 108
                     $extraSyntax = 'ALTER TABLE '.$this->table.' '.$extra.'';
109 109
 
110
-                    $query=$this->schema->getConnection()->setQueryBasic($extraSyntax);
110
+                    $query = $this->schema->getConnection()->setQueryBasic($extraSyntax);
111 111
                 }
112 112
             }
113 113
 
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
      */
130 130
     private function dropColumn($alterType)
131 131
     {
132
-        if(isset($this->syntax[0])){
132
+        if (isset($this->syntax[0])) {
133 133
 
134 134
             $column = rtrim($this->syntax[0]);
135 135
 
136 136
             $alterSytanx = 'alter table '.$this->table.' drop column '.$column;
137 137
 
138
-            $query=$this->schema->getConnection()->setQueryBasic($alterSytanx);
138
+            $query = $this->schema->getConnection()->setQueryBasic($alterSytanx);
139 139
 
140 140
             return [
141 141
                 'syntax'=>$this->syntax,
@@ -162,32 +162,32 @@  discard block
 block discarded – undo
162 162
 
163 163
         $this->getDefaultSyntaxGroup();
164 164
 
165
-        $this->syntax[]=')';
165
+        $this->syntax[] = ')';
166 166
 
167 167
         //get table collation
168
-        if(isset($this->data['tableCollation']['table'])){
169
-            $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table'];
168
+        if (isset($this->data['tableCollation']['table'])) {
169
+            $this->syntax[] = ' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table'];
170 170
         }
171
-        else{
172
-            $this->syntax[]=' DEFAULT CHARACTER SET utf8';
171
+        else {
172
+            $this->syntax[] = ' DEFAULT CHARACTER SET utf8';
173 173
         }
174 174
 
175 175
         //get engine
176
-        if($this->data['engine']!==null)
176
+        if ($this->data['engine']!==null)
177 177
         {
178
-            $this->syntax[]=' ENGINE='.$this->data['engine'].' ';
178
+            $this->syntax[] = ' ENGINE='.$this->data['engine'].' ';
179 179
         }
180
-        else{
181
-            $this->syntax[]=' ENGINE=InnoDB ';
180
+        else {
181
+            $this->syntax[] = ' ENGINE=InnoDB ';
182 182
         }
183 183
 
184
-        $syntax = implode("",$this->syntax);
184
+        $syntax = implode("", $this->syntax);
185 185
 
186
-        if(in_array($this->table,$existTables)){
186
+        if (in_array($this->table, $existTables)) {
187 187
             return false;
188 188
         }
189
-        else{
190
-            $query=$this->schema->getConnection()->setQueryBasic($syntax);
189
+        else {
190
+            $query = $this->schema->getConnection()->setQueryBasic($syntax);
191 191
 
192 192
             return [
193 193
                 'syntax'=>$syntax,
@@ -202,41 +202,41 @@  discard block
 block discarded – undo
202 202
     /**
203 203
      * @param null $group
204 204
      */
205
-    private function getDefaultSyntaxGroup($group=null)
205
+    private function getDefaultSyntaxGroup($group = null)
206 206
     {
207
-        $this->syntax[]=implode(",",$this->getCreateDefaultList());
207
+        $this->syntax[] = implode(",", $this->getCreateDefaultList());
208 208
         
209 209
         //get unique values
210
-        if(isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])){
210
+        if (isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])) {
211 211
             
212
-            if($group=='create'){
213
-                $this->syntax[]=','.implode(',',$this->data['uniqueValueList']);
212
+            if ($group=='create') {
213
+                $this->syntax[] = ','.implode(',', $this->data['uniqueValueList']);
214 214
             }
215
-            else{
216
-                $this->alterExtras[]='ADD '.implode(',',$this->data['uniqueValueList']);
215
+            else {
216
+                $this->alterExtras[] = 'ADD '.implode(',', $this->data['uniqueValueList']);
217 217
             }
218 218
             
219 219
         }
220 220
 
221 221
         //get index values
222
-        if(isset($this->data['indexValueList']) && count($this->data['indexValueList'])){
222
+        if (isset($this->data['indexValueList']) && count($this->data['indexValueList'])) {
223 223
 
224
-            if($group=='create'){
225
-                $this->syntax[]=','.implode(',',$this->data['indexValueList']);
224
+            if ($group=='create') {
225
+                $this->syntax[] = ','.implode(',', $this->data['indexValueList']);
226 226
             }
227
-            else{
228
-                $this->alterExtras[]='ADD '.implode(',',$this->data['indexValueList']); 
227
+            else {
228
+                $this->alterExtras[] = 'ADD '.implode(',', $this->data['indexValueList']); 
229 229
             }
230 230
             
231 231
         }
232 232
 
233 233
         //get index values for key
234
-        if(count($this->getKeyList())){
235
-            $this->syntax[]=','.implode(',',$this->getKeyList());
234
+        if (count($this->getKeyList())) {
235
+            $this->syntax[] = ','.implode(',', $this->getKeyList());
236 236
         }
237 237
 
238
-        if(count($this->data['references'])){
239
-            $this->syntax[]=$this->getReferenceSyntax($this->data['references']);
238
+        if (count($this->data['references'])) {
239
+            $this->syntax[] = $this->getReferenceSyntax($this->data['references']);
240 240
         }
241 241
     }
242 242
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
             if(current($syntaxList)!==$changeAbleField){
96 96
                 $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).'  '.implode(' ',array_splice($syntaxList,1)).' '.$placeList;
97
-            }
98
-            else{
97
+            } else{
99 98
                 $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList;
100 99
             }
101 100
 
@@ -167,8 +166,7 @@  discard block
 block discarded – undo
167 166
         //get table collation
168 167
         if(isset($this->data['tableCollation']['table'])){
169 168
             $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table'];
170
-        }
171
-        else{
169
+        } else{
172 170
             $this->syntax[]=' DEFAULT CHARACTER SET utf8';
173 171
         }
174 172
 
@@ -176,8 +174,7 @@  discard block
 block discarded – undo
176 174
         if($this->data['engine']!==null)
177 175
         {
178 176
             $this->syntax[]=' ENGINE='.$this->data['engine'].' ';
179
-        }
180
-        else{
177
+        } else{
181 178
             $this->syntax[]=' ENGINE=InnoDB ';
182 179
         }
183 180
 
@@ -185,8 +182,7 @@  discard block
 block discarded – undo
185 182
 
186 183
         if(in_array($this->table,$existTables)){
187 184
             return false;
188
-        }
189
-        else{
185
+        } else{
190 186
             $query=$this->schema->getConnection()->setQueryBasic($syntax);
191 187
 
192 188
             return [
@@ -211,8 +207,7 @@  discard block
 block discarded – undo
211 207
             
212 208
             if($group=='create'){
213 209
                 $this->syntax[]=','.implode(',',$this->data['uniqueValueList']);
214
-            }
215
-            else{
210
+            } else{
216 211
                 $this->alterExtras[]='ADD '.implode(',',$this->data['uniqueValueList']);
217 212
             }
218 213
             
@@ -223,8 +218,7 @@  discard block
 block discarded – undo
223 218
 
224 219
             if($group=='create'){
225 220
                 $this->syntax[]=','.implode(',',$this->data['indexValueList']);
226
-            }
227
-            else{
221
+            } else{
228 222
                 $this->alterExtras[]='ADD '.implode(',',$this->data['indexValueList']); 
229 223
             }
230 224
             
Please login to merge, or discard this patch.