Completed
Push — master ( 8d804e...0560b7 )
by Amine
15s queued 12s
created
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.
src/Commands/MigrationCommand.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         if(! $file){
38 38
             $file = date('Y_m_d_His_') . $snakeName . '_table';
39 39
             $this->deleteOldMigration($snakeName);
40
-        }else{
40
+        } else{
41 41
             $this->deleteOldMigration($file);
42 42
         }
43 43
 
@@ -47,7 +47,9 @@  discard block
 block discarded – undo
47 47
     protected function deleteOldMigration($fileName)
48 48
     {
49 49
         foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo){
50
-            if($fileInfo->isDot()) continue;
50
+            if($fileInfo->isDot()) {
51
+                continue;
52
+            }
51 53
 
52 54
             if(strpos($fileInfo->getFilename(), $fileName) !== FALSE){
53 55
                 unlink($fileInfo->getPathname());
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
             ->get();
35 35
 
36 36
         $file = $this->option('file');
37
-        if(! $file){
37
+        if (!$file) {
38 38
             $file = date('Y_m_d_His_') . $snakeName . '_table';
39 39
             $this->deleteOldMigration($snakeName);
40
-        }else{
40
+        } else {
41 41
             $this->deleteOldMigration($file);
42 42
         }
43 43
 
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 
47 47
     protected function deleteOldMigration($fileName)
48 48
     {
49
-        foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo){
50
-            if($fileInfo->isDot()) continue;
49
+        foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo) {
50
+            if ($fileInfo->isDot()) continue;
51 51
 
52
-            if(strpos($fileInfo->getFilename(), $fileName) !== FALSE){
52
+            if (strpos($fileInfo->getFilename(), $fileName) !== FALSE) {
53 53
                 unlink($fileInfo->getPathname());
54 54
             }
55 55
         }
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
     protected function getSchema()
59 59
     {
60 60
         $schema = $this->option('schema');
61
-        if(! $schema){
61
+        if (!$schema) {
62 62
             return $this->spaces(12) . "// Schema declaration";
63 63
         }
64 64
 
65 65
         $items = $schema;
66
-        if( ! $this->option('parsed')){
66
+        if (!$this->option('parsed')) {
67 67
             $items = $this->getArgumentParser('schema')->parse($schema);
68 68
         }
69 69
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $name = $parts[0]['name'];
98 98
         $parts[1]['args'] = array_merge(["'{$name}'"], $parts[1]['args']);
99 99
         unset($parts[0]);
100
-        $parts = array_map(function($part){
100
+        $parts = array_map(function($part) {
101 101
             return '->' . $part['name'] . '(' . implode(', ', $part['args']) . ')';
102 102
         }, $parts);
103 103
         return "            \$table" . implode('', $parts) . ';';
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
     protected function getConstraints()
107 107
     {
108 108
         $keys = $this->option('keys');
109
-        if(! $keys){
109
+        if (!$keys) {
110 110
             return $this->spaces(12) . "// Constraints declaration";
111 111
         }
112 112
 
113 113
         $items = $keys;
114
-        if(! $this->option('parsed')){
114
+        if (!$this->option('parsed')) {
115 115
             $items = $this->getArgumentParser('foreign-keys')->parse($keys);
116 116
         }
117 117
 
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 
126 126
     protected function getConstraintDeclaration($key)
127 127
     {
128
-        if(! $key['column']){
128
+        if (!$key['column']) {
129 129
             $key['column'] = 'id';
130 130
         }
131
-        if(! $key['table']){
131
+        if (!$key['table']) {
132 132
             $key['table'] = \Illuminate\Support\Str::plural(substr($key['name'], 0, strlen($key['name']) - 3));
133 133
         }
134 134
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             ])
141 141
             ->get();
142 142
 
143
-        if($key['on_delete']){
143
+        if ($key['on_delete']) {
144 144
             $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint')
145 145
                     ->with([
146 146
                         'event' => 'Delete',
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
                     ->get();
150 150
         }
151 151
 
152
-        if($key['on_update']){
152
+        if ($key['on_update']) {
153 153
             $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint')
154 154
                     ->with([
155 155
                         'event' => 'Update',
Please login to merge, or discard this patch.
src/Commands/ModelCommand.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 class ModelCommand extends BaseCommand {
5 5
 
6
-	protected $signature = 'wn:model
6
+    protected $signature = 'wn:model
7 7
         {name : Name of the model.}
8 8
         {--fillable= : the fillable fields.}
9 9
         {--guarded= : the guarded fields.}
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         {--force= : override the existing files}
21 21
     ';
22 22
 
23
-	protected $description = 'Generates a model class for a RESTfull resource';
23
+    protected $description = 'Generates a model class for a RESTfull resource';
24 24
 
25 25
     public function handle()
26 26
     {
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 
47 47
     protected function getAsArrayFields($arg, $isOption = true)
48 48
     {
49
-    	$arg = ($isOption) ? $this->option($arg) : $this->argument($arg);
49
+        $arg = ($isOption) ? $this->option($arg) : $this->argument($arg);
50 50
         if(is_string($arg)){
51
-        	$arg = explode(',', $arg);
51
+            $arg = explode(',', $arg);
52 52
         } else if(! is_array($arg)) {
53 53
             $arg = [];
54 54
         }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     protected function getNamespace()
61 61
     {
62
-    	return str_replace(' ', '\\', ucwords(str_replace('/', ' ', $this->option('path'))));
62
+        return str_replace(' ', '\\', ucwords(str_replace('/', ' ', $this->option('path'))));
63 63
     }
64 64
 
65 65
     protected function getRelations()
Please login to merge, or discard this patch.
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -45,6 +45,9 @@  discard block
 block discarded – undo
45 45
         $this->save($content, "./App/Models/{$name}.php", "{$name} model");
46 46
     }
47 47
 
48
+    /**
49
+     * @param string $arg
50
+     */
48 51
     protected function getAsArrayFields($arg, $isOption = true)
49 52
     {
50 53
     	$arg = ($isOption) ? $this->option($arg) : $this->argument($arg);
@@ -79,6 +82,9 @@  discard block
 block discarded – undo
79 82
         return implode(PHP_EOL, $relations);
80 83
     }
81 84
 
85
+    /**
86
+     * @param string $option
87
+     */
82 88
     protected function getImages($option)
83 89
     {
84 90
         $images = [];
@@ -106,6 +112,10 @@  discard block
 block discarded – undo
106 112
         return implode(PHP_EOL, $media);
107 113
     }
108 114
 
115
+    /**
116
+     * @param string $type
117
+     * @param string $option
118
+     */
109 119
     protected function getRelationsByType($type, $option, $withTimestamps = false)
110 120
     {
111 121
         $relations = [];
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
     protected function getAsArrayFields($arg, $isOption = true)
49 49
     {
50 50
     	$arg = ($isOption) ? $this->option($arg) : $this->argument($arg);
51
-        if(is_string($arg)){
51
+        if (is_string($arg)) {
52 52
         	$arg = explode(',', $arg);
53
-        } else if(! is_array($arg)) {
53
+        } else if (!is_array($arg)) {
54 54
             $arg = [];
55 55
         }
56
-        return implode(', ', array_map(function($item){
56
+        return implode(', ', array_map(function($item) {
57 57
             return '"' . $item . '"';
58 58
         }, $arg));
59 59
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             $this->getRelationsByType('belongsToMany', 'belongs-to-many', true)
73 73
         );
74 74
 
75
-        if(empty($relations)){
75
+        if (empty($relations)) {
76 76
             return "    // Relationships";
77 77
         }
78 78
 
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $images = [];
85 85
         $option = $this->option($option);
86
-        if($option){
86
+        if ($option) {
87 87
 
88 88
             $items = $this->getArgumentParser('images')->parse($option);
89 89
 
90 90
             $template = 'model/image';
91 91
             $template = $this->getTemplate($template);
92 92
             foreach ($items as $item) {
93
-                if(! $item['image']){
93
+                if (!$item['image']) {
94 94
                     $item['image'] = "get" . str_replace(' ', '', ucwords(str_replace('_', ' ', $item['name']))) . "Attribute";
95 95
                 }
96 96
                 $images[] = $template->with($item)->get();
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
         $media = array_merge([], $images);
101 101
 
102
-        if(empty($media)){
102
+        if (empty($media)) {
103 103
             return "    // Media methods";
104 104
         }
105 105
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     {
111 111
         $relations = [];
112 112
         $option = $this->option($option);
113
-        if($option){
113
+        if ($option) {
114 114
 
115 115
             $items = $this->getArgumentParser('relations')->parse($option);
116 116
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
             $template = $this->getTemplate($template);
119 119
             foreach ($items as $item) {
120 120
                 $item['type'] = $type;
121
-                if(! $item['model']){
121
+                if (!$item['model']) {
122 122
                     $item['model'] = $this->getNamespace() . '\\' . ucwords(\Illuminate\Support\Str::singular($item['name']));
123
-                } else if(strpos($item['model'], '\\') === false ){
123
+                } else if (strpos($item['model'], '\\') === false) {
124 124
                     $item['model'] = $this->getNamespace() . '\\' . $item['model'];
125 125
                 }
126 126
                 $relations[] = $template->with($item)->get();
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
     protected function getRules()
133 133
     {
134 134
         $rules = $this->option('rules');
135
-        if(! $rules){
135
+        if (!$rules) {
136 136
             return "        // Validation rules";
137 137
         }
138 138
         $items = $rules;
139
-        if(! $this->option('parsed')){
139
+        if (!$this->option('parsed')) {
140 140
             $items = $this->getArgumentParser('rules')->parse($rules);
141 141
         }
142 142
         $rules = [];
Please login to merge, or discard this patch.