Completed
Pull Request — master (#15)
by George
02:11
created
src/Facades/Code.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 namespace Ghaskell\Scaffold\Facades;
10 10
 use Illuminate\Support\Facades\Facade;
11
-class Code extends Facade{
11
+class Code extends Facade {
12 12
     protected static function getFacadeAccessor()
13 13
     {
14 14
         return 'code';
Please login to merge, or discard this patch.
src/Facades/Vibro.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 namespace Ghaskell\Scaffold\Facades;
10 10
 use Illuminate\Support\Facades\Facade;
11
-class Vibro extends Facade{
11
+class Vibro extends Facade {
12 12
     protected static function getFacadeAccessor()
13 13
     {
14 14
         return 'vibro';
Please login to merge, or discard this patch.
src/VibroCompiler.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         extract($data);
67 67
         $parsed = $this->compileString($fileName);
68 68
         ob_start();
69
-        eval( '?>' . $parsed );
69
+        eval('?>'.$parsed);
70 70
         $output = ob_get_contents();
71 71
         ob_end_clean();
72 72
         return $output;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             $result .= is_array($token) ? $this->parseToken($token) : $token;
101 101
         }
102 102
 
103
-        if (! empty($this->rawBlocks)) {
103
+        if (!empty($this->rawBlocks)) {
104 104
             $result = $this->restoreRawContent($result);
105 105
         }
106 106
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     protected function compileStatements($value)
124 124
     {
125 125
         return preg_replace_callback(
126
-            '/\B@%(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?>[^()]+) | (?3) )* \))?/x', function ($match) {
126
+            '/\B@%(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?>[^()]+) | (?3) )* \))?/x', function($match) {
127 127
             return $this->compileStatement($match);
128 128
         }, $value
129 129
         );
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
     {
140 140
         if (Str::contains($match[1], '@%')) {
141 141
             $match[0] = isset($match[3]) ? $match[1].$match[3] : $match[1];
142
-        }  elseif (method_exists($this, $method = 'compile'.ucfirst($match[1]))) {
142
+        } elseif (method_exists($this, $method = 'compile'.ucfirst($match[1]))) {
143 143
             $match[0] = $this->$method(Arr::get($match, 3));
144 144
         }
145 145
 
Please login to merge, or discard this patch.
src/Providers/CodeServiceProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 class CodeServiceProvider extends ServiceProvider
19 19
 {
20
-    const CONFIG_PATH = __DIR__ . './../../config/scaffold.php';
20
+    const CONFIG_PATH = __DIR__.'./../../config/scaffold.php';
21 21
 
22 22
     /**
23 23
      * Register the service provider.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function registerFactory()
42 42
     {
43
-        $this->app->singleton('code', function ($app) {
43
+        $this->app->singleton('code', function($app) {
44 44
             // Next we need to grab the engine resolver instance that will be used by the
45 45
             // environment. The resolver will be used by an environment to get each of
46 46
             // the various engine implementations such as plain PHP or Blade engine.
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function registerViewFinder()
83 83
     {
84
-        $this->app->bind('code.finder', function ($app) {
84
+        $this->app->bind('code.finder', function($app) {
85 85
             return new FileViewFinder($app['files'], $app['config']['view.paths']);
86 86
         });
87 87
     }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function registerEngineResolver()
95 95
     {
96
-        $this->app->singleton('code.engine.resolver', function () {
96
+        $this->app->singleton('code.engine.resolver', function() {
97 97
             $resolver = new EngineResolver;
98 98
 
99 99
             // Next, we will register the various view engines with the resolver so that the
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
         // The Compiler engine requires an instance of the CompilerInterface, which in
117 117
         // this case will be the Blade compiler, so we'll first create the compiler
118 118
         // instance to pass into the engine so it can compile the views properly.
119
-        $this->app->singleton('vibro.compiler', function () {
119
+        $this->app->singleton('vibro.compiler', function() {
120 120
             return new VibroCompiler(
121 121
                 $this->app['files'], $this->app['config']['view.compiled']
122 122
             );
123 123
         });
124 124
 
125
-        $resolver->register('vibro', function () {
125
+        $resolver->register('vibro', function() {
126 126
             return new CodeCompilerEngine($this->app['vibro.compiler']);
127 127
         });
128 128
     }
Please login to merge, or discard this patch.
src/Providers/VibroServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 class VibroServiceProvider extends ViewServiceProvider
16 16
 {
17
-    const CONFIG_PATH = __DIR__ . './../../config/scaffold.php';
17
+    const CONFIG_PATH = __DIR__.'./../../config/scaffold.php';
18 18
 
19 19
     public function boot()
20 20
     {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function register()
27 27
     {
28
-        $this->app->singleton('vibro.compiler', function () {
28
+        $this->app->singleton('vibro.compiler', function() {
29 29
             return new VibroCompiler(
30 30
                 $this->app['files'], $this->app['config']['view.compiled']
31 31
             );
Please login to merge, or discard this patch.
src/ModelPattern.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
             ->parseColumns()
43 43
             ->processColumns();
44 44
         
45
-        $model->namespace = "App\\" . config('scaffold.files.model.path');
46
-        $model->fqname = $model->namespace . "\\" . $model->name;
45
+        $model->namespace = "App\\".config('scaffold.files.model.path');
46
+        $model->fqname = $model->namespace."\\".$model->name;
47 47
         return $model;
48 48
     }
49 49
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
     private function processColumns() {
80
-        foreach($this->columns as $column) {
80
+        foreach ($this->columns as $column) {
81 81
             $this->processColumn($column);
82 82
         }
83 83
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
     public static function arrayStringify($array)
112 112
     {
113
-        if(count($array) > 0) {
113
+        if (count($array) > 0) {
114 114
             $export = str_replace(['array (', ')', '&#40', '&#41'], ['[', ']', '(', ')'], var_export($array, true));
115 115
             $export = preg_replace("/ => \n[^\S\n]*\[/m", ' => [', $export);
116 116
             $export = preg_replace("/ => \[\n[^\S\n]*\]/m", ' => []', $export);
Please login to merge, or discard this patch.
src/Scaffold.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 
30 30
     public static function make($migrationName)
31 31
     {
32
-        $scaffold =  new Scaffold($migrationName);
32
+        $scaffold = new Scaffold($migrationName);
33 33
         $scaffold->files = new Filesystem();
34 34
         $scaffold->files->requireOnce($migrationName);
35 35
         $migrationInstance = $scaffold->resolve($name = $scaffold->getMigrationName($migrationName)); //parse into instance
36
-        $reflector = new \ReflectionClass($migrationInstance);  //reflect
36
+        $reflector = new \ReflectionClass($migrationInstance); //reflect
37 37
         $migrationFileName = $reflector->getFileName();
38 38
         $scaffold->migration = $scaffold->files->get($migrationFileName);
39 39
         $scaffold->model = ModelPattern::make($scaffold->migration);
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function getMigrationFiles($paths)
76 76
     {
77
-        return Collection::make($paths)->flatMap(function ($path) {
77
+        return Collection::make($paths)->flatMap(function($path) {
78 78
             return $this->files->glob($path.'/*_*.php');
79
-        })->filter()->sortBy(function ($file) {
79
+        })->filter()->sortBy(function($file) {
80 80
             return $this->getMigrationName($file);
81
-        })->values()->keyBy(function ($file) {
81
+        })->values()->keyBy(function($file) {
82 82
             return $this->getMigrationName($file);
83 83
         })->all();
84 84
     }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     protected function getStub($stub)
95 95
     {
96 96
         $stub = Str::camel($stub);
97
-        if($this->files->exists(app_path("Scaffold/stubs/$stub.stub"))) {
97
+        if ($this->files->exists(app_path("Scaffold/stubs/$stub.stub"))) {
98 98
                 return $this->files->get(app_path("Scaffold/stubs/$stub.stub"));
99 99
         } else {
100 100
             return false;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     
111 111
     public function addRoutes()
112 112
     {
113
-        foreach(config('scaffold.routes') as $key => $route)
113
+        foreach (config('scaffold.routes') as $key => $route)
114 114
         {
115 115
             $namespace = Str::studly($key);
116 116
             $routeContent = $this->files->get($route['fileName']);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             )));
121 121
 
122 122
 
123
-            if($key === 'web') {
123
+            if ($key === 'web') {
124 124
                 $routeString = "\n\nRoute::resource('$uri', '$namespace\\{$this->model->name}Controller')->only(['index', 'show']);";
125 125
             } else {
126 126
                 $routeString = "\n\nRoute::apiResource('$uri', '$namespace\\{$this->model->name}Controller');";
@@ -137,18 +137,18 @@  discard block
 block discarded – undo
137 137
     {
138 138
         $target = Str::camel(str_replace('build', '', $file));
139 139
         $config = config("scaffold.files.$target");
140
-        if(empty($config)) {
140
+        if (empty($config)) {
141 141
             throw new ScaffoldException("Configuration for $file not found");
142 142
         }
143
-        if(array_key_exists('dedependencies', $config)) {
144
-            foreach($config['dependencies'] as $dependency) {
143
+        if (array_key_exists('dedependencies', $config)) {
144
+            foreach ($config['dependencies'] as $dependency) {
145 145
                 $this->generate($dependency); //recursively generate dependencies
146 146
             }
147 147
         }
148 148
         $pathPrefix = $config['path'];
149 149
         $variables = ['model' => $this->model];
150 150
 
151
-        if(!empty(config("scaffold.variables"))) {
151
+        if (!empty(config("scaffold.variables"))) {
152 152
             foreach (config("scaffold.variables") as $variable => $value) {
153 153
                 $variables[$variable] = $this->compileVariable($value);
154 154
             }
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 
157 157
         $fileName = Vibro::compileFileName($config['fileNamePattern'], $variables);
158 158
         $pathPrefix = base_path(Vibro::compileFileName("$pathPrefix", $variables));
159
-        if($this->files->exists("$pathPrefix/$fileName")) {
159
+        if ($this->files->exists("$pathPrefix/$fileName")) {
160 160
             $this->messages[] = "File '$fileName' exists and was not overwritten.";
161 161
             return $this;
162 162
         }
163 163
 
164
-        if(!$this->files->isDirectory($pathPrefix)) {
164
+        if (!$this->files->isDirectory($pathPrefix)) {
165 165
             $this->files->makeDirectory("$pathPrefix");
166 166
         }
167 167
 
168 168
         $content = $this->build($target, $variables);
169
-        if($content) {
169
+        if ($content) {
170 170
             $this->files->put("$pathPrefix/$fileName", $content);
171 171
             $this->created[] = "$pathPrefix/$fileName";
172 172
         } else {
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     public function compileVariable($string) {
181 181
         $model = $this->model;
182 182
         ob_start();
183
-        eval( "echo $string;");
183
+        eval("echo $string;");
184 184
         $output = ob_get_contents();
185 185
         ob_end_clean();
186 186
 
Please login to merge, or discard this patch.
src/ColumnPattern.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
     public $config;
17 17
 
18 18
     public static function make(string $name, string $type) {
19
-        $column  = new ColumnPattern();
19
+        $column = new ColumnPattern();
20 20
         $column->name = $name;
21 21
         $column->type = $type;
22
-        if(!empty(config("scaffold.columnTypes.$type"))) {
23
-            foreach(config("scaffold.columnTypes.$type") as $key => $value) {
22
+        if (!empty(config("scaffold.columnTypes.$type"))) {
23
+            foreach (config("scaffold.columnTypes.$type") as $key => $value) {
24 24
                 $key = str_replace('"', "", $key);
25 25
                 $column->{$key} = $value;
26 26
             }
Please login to merge, or discard this patch.
src/Console/Commands/ScaffoldGenerate.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
             $scaffold = Scaffold::make($migration);
77 77
             $file = $files[$key];
78 78
             $scaffold->generate($key);
79
-            if(!empty($file['dependencies'])) {
80
-                foreach($file['dependencies'] as $dependency)
79
+            if (!empty($file['dependencies'])) {
80
+                foreach ($file['dependencies'] as $dependency)
81 81
                 {
82 82
                     $scaffold->generate($dependency);
83 83
                 }
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
             
86 86
             $scaffold->addRoutes();
87 87
 
88
-            foreach($scaffold->created as $created) {
88
+            foreach ($scaffold->created as $created) {
89 89
                 $this->info("File '$created' generated.");
90 90
             }
91
-            foreach($scaffold->messages as $message) {
91
+            foreach ($scaffold->messages as $message) {
92 92
                 $this->comment($message);
93 93
             }
94 94
             $this->line("------------------------------------------------------------------------------------------------------------------");
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
         $files = $finder->files()
103 103
             ->name('*table.php')
104 104
             ->notName('2014*')
105
-            ->in(database_path() . '/migrations');
105
+            ->in(database_path().'/migrations');
106 106
 
107 107
         foreach ($files as $file) {
108
-            $this->migrations[] = $file->getRealPath() ;
108
+            $this->migrations[] = $file->getRealPath();
109 109
         }
110 110
     }
111 111
 }
Please login to merge, or discard this patch.