Completed
Push — master ( c585f2...73e470 )
by Amine
11s
created
lumen-test/database/factories/ModelFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 |
12 12
 */
13 13
 
14
-$factory->define(App\User::class, function ($faker) {
14
+$factory->define(App\User::class, function($faker) {
15 15
     return [
16 16
         'name' => $faker->name,
17 17
         'email' => $faker->email,
Please login to merge, or discard this patch.
lumen-test/app/Http/routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,6 +11,6 @@
 block discarded – undo
11 11
 |
12 12
 */
13 13
 
14
-$app->get("/", function () use ($app) {
14
+$app->get("/", function() use ($app) {
15 15
     return $app->welcome();
16 16
 });
Please login to merge, or discard this patch.
src/Commands/ControllerCommand.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,6 @@
 block discarded – undo
1 1
 <?php namespace Wn\Generators\Commands;
2 2
 
3 3
 
4
-use InvalidArgumentException;
5
-
6 4
 class ControllerCommand extends BaseCommand {
7 5
 
8 6
 	protected $signature = 'wn:controller
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,33 +5,33 @@
 block discarded – undo
5 5
 
6 6
 class ControllerCommand extends BaseCommand {
7 7
 
8
-	protected $signature = 'wn:controller
8
+    protected $signature = 'wn:controller
9 9
         {model : Name of the model (with namespace if not App)}
10 10
 		{--no-routes= : without routes}
11 11
         {--force= : override the existing files}
12 12
         {--laravel : Use Laravel style route definitions}
13 13
     ';
14 14
 
15
-	protected $description = 'Generates RESTful controller using the RESTActions trait';
15
+    protected $description = 'Generates RESTful controller using the RESTActions trait';
16 16
 
17 17
     public function handle()
18 18
     {
19
-    	$model = $this->argument('model');
20
-    	$name = '';
21
-    	if(strrpos($model, "\\") === false){
22
-    		$name = $model;
23
-    		$model = "App\\" . $model;
24
-    	} else {
25
-    		$name = explode("\\", $model);
26
-    		$name = $name[count($name) - 1];
27
-    	}
19
+        $model = $this->argument('model');
20
+        $name = '';
21
+        if(strrpos($model, "\\") === false){
22
+            $name = $model;
23
+            $model = "App\\" . $model;
24
+        } else {
25
+            $name = explode("\\", $model);
26
+            $name = $name[count($name) - 1];
27
+        }
28 28
         $controller = ucwords(str_plural($name)) . 'Controller';
29 29
         $content = $this->getTemplate('controller')
30
-        	->with([
31
-        		'name' => $controller,
32
-        		'model' => $model
33
-        	])
34
-        	->get();
30
+            ->with([
31
+                'name' => $controller,
32
+                'model' => $model
33
+            ])
34
+            ->get();
35 35
 
36 36
         $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}");
37 37
         if(! $this->option('no-routes')){
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     {
19 19
     	$model = $this->argument('model');
20 20
     	$name = '';
21
-    	if(strrpos($model, "\\") === false){
21
+    	if (strrpos($model, "\\") === false) {
22 22
     		$name = $model;
23 23
     		$model = "App\\" . $model;
24 24
     	} else {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         	->get();
35 35
 
36 36
         $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}");
37
-        if(! $this->option('no-routes')){
37
+        if (!$this->option('no-routes')) {
38 38
             $options = [
39 39
                 'resource' => snake_case($name, '-'),
40 40
                 '--controller' => $controller,
Please login to merge, or discard this patch.
src/Commands/ResourceCommand.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,6 @@
 block discarded – undo
1 1
 <?php namespace Wn\Generators\Commands;
2 2
 
3 3
 
4
-use InvalidArgumentException;
5
-
6 4
 class ResourceCommand extends BaseCommand {
7 5
 
8 6
     protected $signature = 'wn:resource
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         ]);
62 62
 
63 63
         // generating REST actions trait if doesn't exist
64
-        if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){
64
+        if (!$this->fs->exists('./app/Http/Controllers/RESTActions.php')) {
65 65
             $this->call('wn:controller:rest-actions');
66 66
         }
67 67
         // generating the controller and routes
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
     protected function parseFields()
94 94
     {
95 95
         $fields = $this->argument('fields');
96
-        if($this->option('parsed')){
96
+        if ($this->option('parsed')) {
97 97
             $this->fields = $fields;
98 98
         } else {
99
-            if(! $fields){
99
+            if (!$fields) {
100 100
                 $this->fields = [];
101 101
             } else {
102 102
                 $this->fields = $this->getArgumentParser('fields')
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
     protected function fieldsHavingTag($tag)
122 122
     {
123
-        return array_map(function($field){
123
+        return array_map(function($field) {
124 124
             return $field['name'];
125 125
         }, array_filter($this->fields, function($field) use($tag){
126 126
             return in_array($tag, $field['tags']);
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
 
130 130
     protected function rules()
131 131
     {
132
-        return array_map(function($field){
132
+        return array_map(function($field) {
133 133
             return [
134 134
                 'name' => $field['name'],
135 135
                 'rule' => $field['rules']
136 136
             ];
137
-        }, array_filter($this->fields, function($field){
137
+        }, array_filter($this->fields, function($field) {
138 138
             return !empty($field['rules']);
139 139
         }));
140 140
     }
141 141
 
142 142
     protected function schema()
143 143
     {
144
-        return array_map(function($field){
144
+        return array_map(function($field) {
145 145
             return array_merge([[
146 146
                 'name' => $field['name'],
147 147
                 'args' => []
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
     protected function foreignKeys()
153 153
     {
154 154
         $belongsTo = $this->option('belongs-to');
155
-        if(! $belongsTo) {
155
+        if (!$belongsTo) {
156 156
             return [];
157 157
         }
158 158
         $relations = $this->getArgumentParser('relations')->parse($belongsTo);
159
-        return array_map(function($relation){
159
+        return array_map(function($relation) {
160 160
             $name = $relation['model'] ? $relation['model'] : $relation['name'];
161 161
             $index = strrpos($name, "\\");
162
-            if($index) {
162
+            if ($index) {
163 163
                 $name = substr($name, $index + 1);
164 164
             }
165 165
             return snake_case(str_singular($name)) . '_id';
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 
181 181
     protected function factoryFields()
182 182
     {
183
-        return array_map(function($field){
183
+        return array_map(function($field) {
184 184
             return [
185 185
                 'name' => $field['name'],
186 186
                 'type' => $field['factory']
187 187
             ];
188
-        }, array_filter($this->fields, function($field){
188
+        }, array_filter($this->fields, function($field) {
189 189
             return isset($field['factory']) && $field['factory'];
190 190
         }));
191 191
     }
Please login to merge, or discard this patch.
src/Commands/ResourcesCommand.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php namespace Wn\Generators\Commands;
2 2
 
3
-use InvalidArgumentException;
4 3
 use Symfony\Component\Yaml\Yaml;
5 4
 
6 5
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
         $content = Yaml::parse($content);
25 25
 
26 26
         $modelIndex = 0;
27
-        foreach ($content as $model => $i){
27
+        foreach ($content as $model => $i) {
28 28
             $i = $this->getResourceParams($model, $i);
29
-            $migrationName = 'Create' .  ucwords(str_plural($i['name']));
30
-            $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex , 3, 0, STR_PAD_LEFT) . '_' . snake_case($migrationName) . '_table';
29
+            $migrationName = 'Create' . ucwords(str_plural($i['name']));
30
+            $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex, 3, 0, STR_PAD_LEFT) . '_' . snake_case($migrationName) . '_table';
31 31
 
32 32
 
33 33
             $options = [
@@ -78,34 +78,34 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $i['name'] = snake_case($modelName);
80 80
 
81
-        foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){
82
-            if(isset($i[$relation])){
81
+        foreach (['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation) {
82
+            if (isset($i[$relation])) {
83 83
                 $i[$relation] = $this->convertArray($i[$relation], ' ', ',');
84 84
             } else {
85 85
                 $i[$relation] = false;
86 86
             }
87 87
         }
88 88
 
89
-        if($i['belongsToMany']){
89
+        if ($i['belongsToMany']) {
90 90
             $relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']);
91
-            foreach ($relations as $relation){
91
+            foreach ($relations as $relation) {
92 92
                 $table = '';
93 93
 
94
-                if(! $relation['model']){
94
+                if (!$relation['model']) {
95 95
                     $table = snake_case($relation['name']);
96 96
                 } else {
97 97
                     $names = array_reverse(explode("\\", $relation['model']));
98 98
                     $table = snake_case($names[0]);
99 99
                 }
100 100
 
101
-                $tables = [ str_singular($table), $i['name'] ];
101
+                $tables = [str_singular($table), $i['name']];
102 102
                 sort($tables);
103 103
                 $this->pivotTables[] = $tables;
104 104
             }
105 105
         }
106 106
 
107 107
         $fields = [];
108
-        foreach($i['fields'] as $name => $value) {
108
+        foreach ($i['fields'] as $name => $value) {
109 109
             $value['name'] = $name;
110 110
             $fields[] = $this->serializeField($value);
111 111
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         $string = "{$name};{$schema};{$rules};{$tags}";
128 128
 
129
-        if(isset($field['factory']) && !empty($field['factory'])){
129
+        if (isset($field['factory']) && !empty($field['factory'])) {
130 130
             $string .= ';' . $field['factory'];
131 131
         }
132 132
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
     protected function convertArray($list, $old, $new)
137 137
     {
138
-        return implode($new, array_filter(explode($old, $list), function($item){
138
+        return implode($new, array_filter(explode($old, $list), function($item) {
139 139
             return !empty($item);
140 140
         }));
141 141
     }
Please login to merge, or discard this patch.
src/Commands/RouteCommand.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,6 @@
 block discarded – undo
1 1
 <?php namespace Wn\Generators\Commands;
2 2
 
3 3
 
4
-use InvalidArgumentException;
5
-
6 4
 class RouteCommand extends BaseCommand {
7 5
 
8 6
 	protected $signature = 'wn:route
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
     protected function getController()
68 68
     {
69 69
         $controller = $this->option('controller');
70
-        if(! $controller){
70
+        if (!$controller) {
71 71
             $controller = ucwords(str_plural(camel_case($this->argument('resource')))) . 'Controller';
72 72
         }
73 73
         return $controller;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
5 5
 
6 6
 class RouteCommand extends BaseCommand {
7 7
 
8
-	protected $signature = 'wn:route
8
+    protected $signature = 'wn:route
9 9
 		{resource : Name of the resource.}
10 10
         {--controller= : Name of the RESTful controller.}
11 11
         {--laravel= : Use Laravel style route definitions}
12 12
     ';
13 13
 
14
-	protected $description = 'Generates RESTful routes.';
14
+    protected $description = 'Generates RESTful routes.';
15 15
 
16 16
     public function handle()
17 17
     {
Please login to merge, or discard this patch.
lumen-test/tests/acceptance/RouteCommandCept.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
 
64 64
 $I->wantTo('run wn:routes in Lumen 5.3+');
65
-if(!file_exists('./routes')) {
65
+if (!file_exists('./routes')) {
66 66
     mkdir('./routes');
67 67
 }
68 68
 $I->writeToFile('./routes/web.php', '<?php
Please login to merge, or discard this patch.