Passed
Pull Request — master (#3)
by
unknown
02:31
created
src/Schema.php 1 patch
Spacing   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
     protected function create()
46 46
     {
47
-        if($this->columnsList()->isEmpty()) {
47
+        if ($this->columnsList()->isEmpty()) {
48 48
             return $this->output()->error("Table <fg=black;bg=white> {$this->table} </> does not have any columns");
49 49
         }
50 50
 
51
-        LaravelSchema::create($this->name, function (Blueprint $table) {
51
+        LaravelSchema::create($this->name, function(Blueprint $table) {
52 52
             eval($this->schema->group(2));
53 53
         });
54 54
 
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 
58 58
     protected function sync()
59 59
     {
60
-        if($this->schemaEmpty()) {
60
+        if ($this->schemaEmpty()) {
61 61
             return $this->dropSchema();
62 62
         }
63 63
 
64
-        $this->dbUnsyncedColumns()->each(function ($type, $column)  {
64
+        $this->dbUnsyncedColumns()->each(function($type, $column) {
65 65
             $this->output()->info("Column <fg=black;bg=yellow> {$this->table}->{$column} </> is renamed or deleted !!");
66 66
             $action = $this->output()->choice('What we should do ?', $this->syncChoices(), 0);
67 67
 
68 68
             (new Column($this))->$action($column);
69 69
         });
70 70
 
71
-        $this->schemaUnsyncedColumns()->each(function ($column, $line) {
71
+        $this->schemaUnsyncedColumns()->each(function($column, $line) {
72 72
             (new Column($this))->create($line, $column);
73 73
         });
74 74
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     protected function getName($name)
89 89
     {
90 90
         //TODO: https://github.com/awssat/laravel-sync-migration/issues/2
91
-        if(preg_match('/[\'|"]\s?\.\s?\$/', $name) || preg_match('/\$[a-zA-z0-9-_]+\s?\.\s?[\'|"]/', $name)) {
91
+        if (preg_match('/[\'|"]\s?\.\s?\$/', $name) || preg_match('/\$[a-zA-z0-9-_]+\s?\.\s?[\'|"]/', $name)) {
92 92
             $this->output()->error("Using variables as table names (<fg=black;bg=white> {$name} </>) is not supported currentlly, see <href=https://github.com/awssat/laravel-sync-migration/issues/2> issue#2 </>");
93 93
             exit;
94 94
         }
@@ -103,38 +103,37 @@  discard block
 block discarded – undo
103 103
 
104 104
     protected function dbUnsyncedColumns()
105 105
     {
106
-        return $this->dbColumns()->reject(function ($type, $column) {
106
+        return $this->dbColumns()->reject(function($type, $column) {
107 107
             return $this->columnsList()->values()->flatten()->contains($column);
108 108
         });
109 109
     }
110 110
 
111 111
     protected function schemaUnsyncedColumns()
112 112
     {
113
-        return $this->columnsList()->reject(function ($column) {
113
+        return $this->columnsList()->reject(function($column) {
114 114
             return $this->dbColumns()->has($column);
115 115
         });
116 116
     }
117 117
 
118 118
     protected function syncChoices()
119 119
     {
120
-        return $this->schemaUnsyncedColumns()->isEmpty() ? ['Delete', 'Ignore'] :
121
-            ['Delete', 'Rename', 'Ignore'];
120
+        return $this->schemaUnsyncedColumns()->isEmpty() ? ['Delete', 'Ignore'] : ['Delete', 'Rename', 'Ignore'];
122 121
     }
123 122
 
124 123
     protected function dbColumns()
125 124
     {
126 125
         return collect(DB::select('DESCRIBE ' . $this->table))
127
-            ->mapWithKeys(function ($column) {
126
+            ->mapWithKeys(function($column) {
128 127
             return [$column->Field => $column->Type];
129 128
         });
130 129
     }
131 130
 
132 131
     protected function columnsList()
133 132
     {
134
-        return collect(explode(';', $this->schema->group(2)))->mapWithKeys(function ($line) {
133
+        return collect(explode(';', $this->schema->group(2)))->mapWithKeys(function($line) {
135 134
             $line = trim($line);
136 135
 
137
-            if(starts_with($line, ['//', '#', '/*'])) {
136
+            if (starts_with($line, ['//', '#', '/*'])) {
138 137
                 return [];
139 138
             }
140 139
 
Please login to merge, or discard this patch.