Completed
Push — master ( 3f0582...5810d4 )
by Amo
02:56
created
src/Commands/ResourceMakeCommand.php 2 patches
Doc Comments   +23 added lines patch added patch discarded remove patch
@@ -93,6 +93,9 @@  discard block
 block discarded – undo
93 93
         $this->createModelFactory($name);
94 94
     }
95 95
 
96
+    /**
97
+     * @param string $name
98
+     */
96 99
     private function createModelFactory($name)
97 100
     {
98 101
         $model = $this->modelName($name);
@@ -162,6 +165,9 @@  discard block
 block discarded – undo
162 165
         return true;
163 166
     }
164 167
 
168
+    /**
169
+     * @param string $name
170
+     */
165 171
     private function createMigration($name)
166 172
     {
167 173
         $filename = $this->buildMigrationFilename($name);
@@ -187,6 +193,9 @@  discard block
 block discarded – undo
187 193
         return true;
188 194
     }
189 195
 
196
+    /**
197
+     * @param string $modelName
198
+     */
190 199
     private function createController($modelName)
191 200
     {
192 201
         $filename = ucfirst($modelName) . 'Controller.php';
@@ -209,6 +218,9 @@  discard block
 block discarded – undo
209 218
         return true;
210 219
     }
211 220
 
221
+    /**
222
+     * @param string $modelName
223
+     */
212 224
     private function appendRoutes($modelName)
213 225
     {
214 226
         $modelTitle = ucfirst($modelName);
@@ -251,6 +263,11 @@  discard block
 block discarded – undo
251 263
         return $stub;
252 264
     }
253 265
 
266
+    /**
267
+     * @param string $name
268
+     *
269
+     * @return string
270
+     */
254 271
     protected function buildModel($name)
255 272
     {
256 273
         $stub = $this->files->get(__DIR__ . '/../Stubs/model.stub');
@@ -278,6 +295,9 @@  discard block
 block discarded – undo
278 295
         return date('Y_m_d_his') . '_create_' . $table . '_table.php';
279 296
     }
280 297
 
298
+    /**
299
+     * @param string $stub
300
+     */
281 301
     private function replaceClassName($name, $stub)
282 302
     {
283 303
         return str_replace('NAME_PLACEHOLDER', $name, $stub);
@@ -346,6 +366,9 @@  discard block
 block discarded – undo
346 366
         return $string;
347 367
     }
348 368
 
369
+    /**
370
+     * @param string $name
371
+     */
349 372
     public function addModelAttributes($name, $attributes, $stub)
350 373
     {
351 374
         $attributes = '[' . collect($this->parseAttributesFromInputString($attributes))
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
     {
98 98
         $model = $this->modelName($name);
99 99
 
100
-        $stub = $this->files->get(__DIR__ . '/../Stubs/factory.stub');
100
+        $stub = $this->files->get(__DIR__.'/../Stubs/factory.stub');
101 101
 
102 102
         $stub = str_replace('CLASSNAME', $model, $stub);
103 103
 
104
-        $class = 'App\\' . $model;
104
+        $class = 'App\\'.$model;
105 105
         $model = new $class;
106 106
 
107 107
         $stub = str_replace(
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
             $method = $formatter['method'];
130 130
             $parameters = $formatter['parameters'];
131 131
 
132
-            $faker .= "'".$attribute['name']."' => \$faker->".$method."(".$parameters.")," . PHP_EOL . '        ';
132
+            $faker .= "'".$attribute['name']."' => \$faker->".$method."(".$parameters."),".PHP_EOL.'        ';
133 133
 
134 134
         }
135 135
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     {
147 147
         $modelName = $this->modelName($name);
148 148
 
149
-        $filename = $modelName . '.php';
149
+        $filename = $modelName.'.php';
150 150
 
151 151
         if ($this->files->exists(app_path($filename))) {
152 152
             $this->error('Model already exists!');
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
         $model = $this->buildModel($name);
157 157
 
158
-        $this->files->put(app_path('/' . $filename), $model);
158
+        $this->files->put(app_path('/'.$filename), $model);
159 159
 
160
-        $this->info($modelName . ' Model created');
160
+        $this->info($modelName.' Model created');
161 161
 
162 162
         return true;
163 163
     }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
         $migration = $this->buildMigration($name);
175 175
 
176 176
         $this->files->put(
177
-            database_path('/migrations/' . $filename),
177
+            database_path('/migrations/'.$filename),
178 178
             $migration
179 179
         );
180 180
 
@@ -182,29 +182,29 @@  discard block
 block discarded – undo
182 182
             $this->composer->dumpAutoloads();
183 183
         }
184 184
 
185
-        $this->info('Created migration ' . $filename);
185
+        $this->info('Created migration '.$filename);
186 186
 
187 187
         return true;
188 188
     }
189 189
 
190 190
     private function createController($modelName)
191 191
     {
192
-        $filename = ucfirst($modelName) . 'Controller.php';
192
+        $filename = ucfirst($modelName).'Controller.php';
193 193
 
194
-        if ($this->files->exists(app_path('Http/' . $filename))) {
194
+        if ($this->files->exists(app_path('Http/'.$filename))) {
195 195
             $this->error('Controller already exists!');
196 196
             return false;
197 197
         }
198 198
 
199
-        $stub = $this->files->get(__DIR__ . '/../Stubs/controller.stub');
199
+        $stub = $this->files->get(__DIR__.'/../Stubs/controller.stub');
200 200
 
201 201
         $stub = str_replace('MyModelClass', ucfirst($modelName), $stub);
202 202
         $stub = str_replace('myModelInstance', Str::camel($modelName), $stub);
203 203
         $stub = str_replace('template', strtolower($modelName), $stub);
204 204
 
205
-        $this->files->put(app_path('Http/Controllers/' . $filename), $stub);
205
+        $this->files->put(app_path('Http/Controllers/'.$filename), $stub);
206 206
 
207
-        $this->info('Created controller ' . $filename);
207
+        $this->info('Created controller '.$filename);
208 208
 
209 209
         return true;
210 210
     }
@@ -215,27 +215,27 @@  discard block
 block discarded – undo
215 215
 
216 216
         $modelName = strtolower($modelName);
217 217
 
218
-        $newRoutes = $this->files->get(__DIR__ . '/../Stubs/routes.stub');
218
+        $newRoutes = $this->files->get(__DIR__.'/../Stubs/routes.stub');
219 219
 
220 220
         $newRoutes = str_replace('|MODEL_TITLE|', $modelTitle, $newRoutes);
221 221
 
222 222
         $newRoutes = str_replace('|MODEL_NAME|', $modelName, $newRoutes);
223 223
 
224
-        $newRoutes = str_replace('|CONTROLLER_NAME|', $modelTitle . 'Controller', $newRoutes);
224
+        $newRoutes = str_replace('|CONTROLLER_NAME|', $modelTitle.'Controller', $newRoutes);
225 225
 
226 226
         $this->files->append(
227 227
             app_path('Http/routes.php'),
228 228
             $newRoutes
229 229
         );
230 230
 
231
-        $this->info('Added routes for ' . $modelTitle);
231
+        $this->info('Added routes for '.$modelTitle);
232 232
     }
233 233
 
234 234
     protected function buildMigration($name)
235 235
     {
236
-        $stub = $this->files->get(__DIR__ . '/../Stubs/migration.stub');
236
+        $stub = $this->files->get(__DIR__.'/../Stubs/migration.stub');
237 237
 
238
-        $className = 'Create' . Str::plural($name). 'Table';
238
+        $className = 'Create'.Str::plural($name).'Table';
239 239
 
240 240
         $stub = str_replace('MIGRATION_CLASS_PLACEHOLDER', $className, $stub);
241 241
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
         $stub = str_replace('TABLE_NAME_PLACEHOLDER', $table, $stub);
245 245
 
246
-        $class = 'App\\' . $name;
246
+        $class = 'App\\'.$name;
247 247
         $model = new $class;
248 248
 
249 249
         $stub = str_replace('MIGRATION_COLUMNS_PLACEHOLDER', $this->buildTableColumns($model->migrationAttributes()), $stub);
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 
254 254
     protected function buildModel($name)
255 255
     {
256
-        $stub = $this->files->get(__DIR__ . '/../Stubs/model.stub');
256
+        $stub = $this->files->get(__DIR__.'/../Stubs/model.stub');
257 257
 
258 258
         $stub = $this->replaceClassName($name, $stub);
259 259
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     {
276 276
         $table = $this->convertModelToTableName($model);
277 277
 
278
-        return date('Y_m_d_his') . '_create_' . $table . '_table.php';
278
+        return date('Y_m_d_his').'_create_'.$table.'_table.php';
279 279
     }
280 280
 
281 281
     private function replaceClassName($name, $stub)
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
         foreach ($array as $name => $properties) {
328 328
             $string .= '[';
329
-            $string .= "'name' => '" . $name . "',";
329
+            $string .= "'name' => '".$name."',";
330 330
 
331 331
             $string .= "'properties' => [";
332 332
             foreach ($properties as $property) {
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 
349 349
     public function addModelAttributes($name, $attributes, $stub)
350 350
     {
351
-        $attributes = '[' . collect($this->parseAttributesFromInputString($attributes))
351
+        $attributes = '['.collect($this->parseAttributesFromInputString($attributes))
352 352
             ->filter(function($attribute) use ($name) {
353 353
                 return in_array($name, $attribute);
354
-            })->map(function ($attributes, $name) {
355
-                return "'" . $name . "'";
356
-            })->values()->implode(', ') . ']';
354
+            })->map(function($attributes, $name) {
355
+                return "'".$name."'";
356
+            })->values()->implode(', ').']';
357 357
 
358 358
 
359
-        return str_replace(strtoupper($name) . '_PLACEHOLDER', $attributes, $stub);
359
+        return str_replace(strtoupper($name).'_PLACEHOLDER', $attributes, $stub);
360 360
     }
361 361
 
362 362
     public function buildTableColumns($attributes)
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
             $properties = $this->extractAttributePropertiesToApply($attribute['properties']);
374 374
 
375
-            return $column . $this->buildSchemaColumn($fieldType, $attribute['name'], $length, $properties);
375
+            return $column.$this->buildSchemaColumn($fieldType, $attribute['name'], $length, $properties);
376 376
 
377 377
         }));
378 378
 
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
         // is no matching data type found, the column
394 394
         // should be cast to a string.
395 395
 
396
-        if (! $type) {
396
+        if (!$type) {
397 397
             return 'string';
398 398
         }
399 399
 
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
      */
451 451
     private function buildSchemaColumn($fieldType, $name, $length = 0, $traits = [])
452 452
     {
453
-        return sprintf("\$table->%s('%s'%s)%s;" . PHP_EOL . '            ',
453
+        return sprintf("\$table->%s('%s'%s)%s;".PHP_EOL.'            ',
454 454
             $fieldType,
455 455
             $name,
456 456
             $length > 0 ? ", $length" : '',
457
-            implode('', array_map(function ($trait) {
458
-                return '->' . $trait . '()';
457
+            implode('', array_map(function($trait) {
458
+                return '->'.$trait.'()';
459 459
             }, $traits))
460 460
         );
461 461
     }
Please login to merge, or discard this patch.
src/ResourceGeneratorServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function register()
25 25
     {
26
-        $this->app->singleton('command.drawmyattention.makeresource', function ($app) {
26
+        $this->app->singleton('command.drawmyattention.makeresource', function($app) {
27 27
             return $app['DrawMyAttention\ResourceGenerator\Commands\ResourceMakeCommand'];
28 28
         });
29 29
         $this->commands('command.drawmyattention.makeresource');
Please login to merge, or discard this patch.