@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function handle() |
| 24 | 24 | { |
| 25 | - foreach ($this->tableFilters() as $table=>$files){ |
|
| 25 | + foreach ($this->tableFilters() as $table=>$files) { |
|
| 26 | 26 | |
| 27 | 27 | $table = strtolower($table); |
| 28 | 28 | |
@@ -30,20 +30,20 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $checkMigrationMain = $this->schema->getConnection()->checkMigrationMain(); |
| 32 | 32 | |
| 33 | - if($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])){ |
|
| 34 | - $this->apply($this->tableFilters()['Migrations'][0],'migrations'); |
|
| 33 | + if ($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])) { |
|
| 34 | + $this->apply($this->tableFilters()['Migrations'][0], 'migrations'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $checkMigration = $this->schema->getConnection()->checkMigration($table,$file); |
|
| 37 | + $checkMigration = $this->schema->getConnection()->checkMigration($table, $file); |
|
| 38 | 38 | |
| 39 | - if(!$checkMigration){ |
|
| 39 | + if (!$checkMigration) { |
|
| 40 | 40 | |
| 41 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
| 41 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
| 42 | 42 | $className = $this->getClassName($getClassName); |
| 43 | 43 | |
| 44 | 44 | require_once ($file); |
| 45 | 45 | |
| 46 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
| 46 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
| 47 | 47 | |
| 48 | 48 | $this->list[$table][] = (new $className)->up($capsule); |
| 49 | 49 | } |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | * @param $table |
| 61 | 61 | * @return mixed|string |
| 62 | 62 | */ |
| 63 | - public function apply($file,$table) |
|
| 63 | + public function apply($file, $table) |
|
| 64 | 64 | { |
| 65 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
| 65 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
| 66 | 66 | $className = $this->getClassName($getClassName); |
| 67 | 67 | |
| 68 | 68 | require_once ($file); |
| 69 | 69 | |
| 70 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
| 70 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
| 71 | 71 | |
| 72 | 72 | $this->list[$table][] = (new $className)->up($capsule); |
| 73 | 73 | |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | * @param $name |
| 11 | 11 | * @return string |
| 12 | 12 | */ |
| 13 | - protected function getNullableValue($nullable,$name) |
|
| 13 | + protected function getNullableValue($nullable, $name) |
|
| 14 | 14 | { |
| 15 | - $nullableValue=''; |
|
| 15 | + $nullableValue = ''; |
|
| 16 | 16 | |
| 17 | - if(isset($nullable[$name])){ |
|
| 18 | - if($nullable[$name]===false){ |
|
| 19 | - $nullableValue='NOT NULL'; |
|
| 17 | + if (isset($nullable[$name])) { |
|
| 18 | + if ($nullable[$name]===false) { |
|
| 19 | + $nullableValue = 'NOT NULL'; |
|
| 20 | 20 | } |
| 21 | - else{ |
|
| 22 | - $nullableValue='NULL'; |
|
| 21 | + else { |
|
| 22 | + $nullableValue = 'NULL'; |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
@@ -59,22 +59,22 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | protected function getValueWithIsset($name) |
| 61 | 61 | { |
| 62 | - $nameKey = array_search($name,$this->data['names']); |
|
| 62 | + $nameKey = array_search($name, $this->data['names']); |
|
| 63 | 63 | |
| 64 | 64 | $list = []; |
| 65 | - $list[] = $this->getNullableValue($this->data['nullable'],$name); |
|
| 65 | + $list[] = $this->getNullableValue($this->data['nullable'], $name); |
|
| 66 | 66 | $list[] = (isset($this->data['autoIncrement'][$name])) ? 'AUTO_INCREMENT' : ''; |
| 67 | 67 | $list[] = (isset($this->data['primaryKey'][$name])) ? 'PRIMARY KEY' : ''; |
| 68 | 68 | |
| 69 | - if(isset($this->data['types'][$nameKey])){ |
|
| 70 | - if($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])){ |
|
| 69 | + if (isset($this->data['types'][$nameKey])) { |
|
| 70 | + if ($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])) { |
|
| 71 | 71 | $this->data['default'][$name] = 'CURRENT_TIMESTAMP'; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if($this->data['types'][$nameKey]!=='timestamp'){ |
|
| 74 | + if ($this->data['types'][$nameKey]!=='timestamp') { |
|
| 75 | 75 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
| 76 | 76 | } |
| 77 | - else{ |
|
| 77 | + else { |
|
| 78 | 78 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if(count($list)===3){ |
|
| 85 | + if (count($list)===3) { |
|
| 86 | 86 | $list[] = ''; |
| 87 | 87 | $list[] = ''; |
| 88 | 88 | } |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | protected function getUniqueValueList($name) |
| 100 | 100 | { |
| 101 | 101 | //get unique |
| 102 | - if(isset($this->data['unique'][$name])){ |
|
| 103 | - $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
| 102 | + if (isset($this->data['unique'][$name])) { |
|
| 103 | + $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | protected function getIndexValueList($name) |
| 111 | 111 | { |
| 112 | 112 | //get index |
| 113 | - if(isset($this->data['index'][$name])){ |
|
| 114 | - $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
| 113 | + if (isset($this->data['index'][$name])) { |
|
| 114 | + $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | protected function getCreateDefaultList() |
| 134 | 134 | { |
| 135 | - $list = []; |
|
| 135 | + $list = []; |
|
| 136 | 136 | |
| 137 | 137 | foreach ($this->data['names'] as $key=>$name) |
| 138 | 138 | { |
| 139 | 139 | list( |
| 140 | - $nullableValue,$autoIncrementValue, |
|
| 141 | - $primaryKeyValue,$defaultValue,$commentValue |
|
| 140 | + $nullableValue, $autoIncrementValue, |
|
| 141 | + $primaryKeyValue, $defaultValue, $commentValue |
|
| 142 | 142 | ) = $this->getValueWithIsset($name); |
| 143 | 143 | |
| 144 | 144 | //set index values |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $types = (isset($this->data['types'][$key])) ? $this->data['types'][$key] : ''; |
| 148 | 148 | |
| 149 | - $list[]=''.$name.' '.$types.' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
| 149 | + $list[] = ''.$name.' '.$types.' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return $list; |
@@ -157,18 +157,18 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function getKeyList() |
| 159 | 159 | { |
| 160 | - $keyList = []; |
|
| 160 | + $keyList = []; |
|
| 161 | 161 | |
| 162 | 162 | //multiple indexes |
| 163 | - if(isset($this->data['index']['indexes'])){ |
|
| 163 | + if (isset($this->data['index']['indexes'])) { |
|
| 164 | 164 | |
| 165 | - foreach ($this->data['index']['indexes'] as $index_key=>$index_value){ |
|
| 165 | + foreach ($this->data['index']['indexes'] as $index_key=>$index_value) { |
|
| 166 | 166 | |
| 167 | 167 | $indexesCommentValue = (isset($index_value['comment'])) ? 'COMMENT "'.$index_value['comment'].'"' : ''; |
| 168 | 168 | |
| 169 | 169 | $keyType = (isset($index_value['type'])) ? ucfirst($index_value['type']) : 'KEY'; |
| 170 | 170 | |
| 171 | - $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",",$index_value['value']).") ".$indexesCommentValue; |
|
| 171 | + $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",", $index_value['value']).") ".$indexesCommentValue; |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -183,13 +183,13 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $list = []; |
| 185 | 185 | |
| 186 | - foreach ($reference as $constraint=>$values){ |
|
| 186 | + foreach ($reference as $constraint=>$values) { |
|
| 187 | 187 | |
| 188 | - $list[]=',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
| 188 | + $list[] = ',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
| 189 | 189 | REFERENCES '.$values['references']['table'].'('.$values['references']['field'].') '.$this->getOnProcess($values); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return implode (" ",$list); |
|
| 192 | + return implode(" ", $list); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | private function getOnProcess($referenceValue) |
| 199 | 199 | { |
| 200 | - if(isset($referenceValue['on']) && isset($referenceValue['onOption'])){ |
|
| 200 | + if (isset($referenceValue['on']) && isset($referenceValue['onOption'])) { |
|
| 201 | 201 | return ''.$referenceValue['on'].' '.strtoupper($referenceValue['onOption']).''; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -17,8 +17,7 @@ discard block |
||
| 17 | 17 | if(isset($nullable[$name])){ |
| 18 | 18 | if($nullable[$name]===false){ |
| 19 | 19 | $nullableValue='NOT NULL'; |
| 20 | - } |
|
| 21 | - else{ |
|
| 20 | + } else{ |
|
| 22 | 21 | $nullableValue='NULL'; |
| 23 | 22 | } |
| 24 | 23 | } |
@@ -73,8 +72,7 @@ discard block |
||
| 73 | 72 | |
| 74 | 73 | if($this->data['types'][$nameKey]!=='timestamp'){ |
| 75 | 74 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
| 76 | - } |
|
| 77 | - else{ |
|
| 75 | + } else{ |
|
| 78 | 76 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
| 79 | 77 | } |
| 80 | 78 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | private function getWizardAlterInstance($group) |
| 80 | 80 | { |
| 81 | - $this->setAlterType('group',$group); |
|
| 81 | + $this->setAlterType('group', $group); |
|
| 82 | 82 | |
| 83 | 83 | return new WizardAlter($this); |
| 84 | 84 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | private function dropWizardAlterInstance($group) |
| 91 | 91 | { |
| 92 | - $this->setAlterType('group',$group); |
|
| 92 | + $this->setAlterType('group', $group); |
|
| 93 | 93 | |
| 94 | 94 | return $this; |
| 95 | 95 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | private function addIndexWizardAlterInstance($group) |
| 102 | 102 | { |
| 103 | - $this->setAlterType('group',$group); |
|
| 103 | + $this->setAlterType('group', $group); |
|
| 104 | 104 | |
| 105 | 105 | return $this; |
| 106 | 106 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | private function addUniqueWizardAlterInstance($group) |
| 113 | 113 | { |
| 114 | - $this->setAlterType('group',$group); |
|
| 114 | + $this->setAlterType('group', $group); |
|
| 115 | 115 | |
| 116 | 116 | return $this; |
| 117 | 117 | } |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | * @param array $uniques |
| 10 | 10 | * @return mixed |
| 11 | 11 | */ |
| 12 | - public function uniques($unique_name,$uniques=array()); |
|
| 12 | + public function uniques($unique_name, $uniques = array()); |
|
| 13 | 13 | } |
| 14 | 14 | |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | * @param array $indexes |
| 10 | 10 | * @return mixed |
| 11 | 11 | */ |
| 12 | - public function indexes($index_name,$indexes=array()); |
|
| 12 | + public function indexes($index_name, $indexes = array()); |
|
| 13 | 13 | } |
| 14 | 14 | |