Completed
Pull Request — master (#72)
by
unknown
01:21
created
lumen-test/tests/_support/_generated/AcceptanceTesterActions.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 // You should not change it manually as it will be overwritten on next build
6 6
 // @codingStandardsIgnoreFile
7 7
 
8
-use Helper\Acceptance;
9 8
 use Codeception\Module\Cli;
10 9
 use Codeception\Module\Filesystem;
11 10
 
Please login to merge, or discard this patch.
lumen-test/tests/_support/_generated/UnitTesterActions.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
 // @codingStandardsIgnoreFile
7 7
 
8 8
 use Codeception\Module\Asserts;
9
-use Helper\Unit;
10 9
 
11 10
 trait UnitTesterActions
12 11
 {
Please login to merge, or discard this patch.
src/Commands/BaseCommand.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -21,16 +21,25 @@  discard block
 block discarded – undo
21 21
         $this->argumentFormatLoader = new ArgumentFormatLoader($fs);
22 22
     }
23 23
 
24
+    /**
25
+     * @param string $name
26
+     */
24 27
     protected function getTemplate($name)
25 28
     {
26 29
         return $this->templates->load($name);
27 30
     }
28 31
 
32
+    /**
33
+     * @param string $name
34
+     */
29 35
     protected function getArgumentParser($name){
30 36
         $format = $this->argumentFormatLoader->load($name);
31 37
         return new ArgumentParser($format);
32 38
     }
33 39
 
40
+    /**
41
+     * @param string $content
42
+     */
34 43
     protected function save($content, $path, $name, $force = false)
35 44
     {
36 45
         if (!$force && $this->fs->exists($path) && $this->input->hasOption('force') && !$this->option('force')) {
@@ -49,6 +58,9 @@  discard block
 block discarded – undo
49 58
         }
50 59
     }
51 60
 
61
+    /**
62
+     * @param integer $n
63
+     */
52 64
     protected function spaces($n)
53 65
     {
54 66
         return str_repeat(' ', $n);
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
 class BaseCommand extends Command {
11 11
 
12 12
     protected $fs;
13
-	protected $templates;
13
+    protected $templates;
14 14
 
15
-	public function __construct(Filesystem $fs)
16
-	{
15
+    public function __construct(Filesystem $fs)
16
+    {
17 17
         parent::__construct();
18 18
 
19 19
         $this->fs = $fs;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
         return $this->templates->load($name);
27 27
     }
28 28
 
29
-    protected function getArgumentParser($name){
29
+    protected function getArgumentParser($name) {
30 30
         $format = $this->argumentFormatLoader->load($name);
31 31
         return new ArgumentParser($format);
32 32
     }
Please login to merge, or discard this patch.
src/Commands/ResourceCommand.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -111,6 +111,9 @@
 block discarded – undo
111 111
 
112 112
     }
113 113
 
114
+    /**
115
+     * @param string $tag
116
+     */
114 117
     protected function fieldsHavingTag($tag)
115 118
     {
116 119
         return array_map(function($field){
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php namespace Wn\Generators\Commands;
2 2
 
3 3
 
4
-use InvalidArgumentException;
5 4
 use Illuminate\Support\Str;
6 5
 
7 6
 class ResourceCommand extends BaseCommand {
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         ]);
63 63
 
64 64
         // generating REST actions trait if doesn't exist
65
-        if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){
65
+        if (!$this->fs->exists('./app/Http/Controllers/RESTActions.php')) {
66 66
             $this->call('wn:controller:rest-actions');
67 67
         }
68 68
         // generating the controller and routes
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
     protected function parseFields()
95 95
     {
96 96
         $fields = $this->argument('fields');
97
-        if($this->option('parsed')){
97
+        if ($this->option('parsed')) {
98 98
             $this->fields = $fields;
99 99
         } else {
100
-            if(! $fields){
100
+            if (!$fields) {
101 101
                 $this->fields = [];
102 102
             } else {
103 103
                 $this->fields = $this->getArgumentParser('fields')
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     protected function fieldsHavingTag($tag)
123 123
     {
124
-        return array_map(function($field){
124
+        return array_map(function($field) {
125 125
             return $field['name'];
126 126
         }, array_filter($this->fields, function($field) use($tag){
127 127
             return in_array($tag, $field['tags']);
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
 
131 131
     protected function rules()
132 132
     {
133
-        return array_map(function($field){
133
+        return array_map(function($field) {
134 134
             return [
135 135
                 'name' => $field['name'],
136 136
                 'rule' => $field['rules']
137 137
             ];
138
-        }, array_filter($this->fields, function($field){
138
+        }, array_filter($this->fields, function($field) {
139 139
             return !empty($field['rules']);
140 140
         }));
141 141
     }
142 142
 
143 143
     protected function schema()
144 144
     {
145
-        return array_map(function($field){
145
+        return array_map(function($field) {
146 146
             return array_merge([[
147 147
                 'name' => $field['name'],
148 148
                 'args' => []
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
     protected function foreignKeys()
154 154
     {
155 155
         $belongsTo = $this->option('belongs-to');
156
-        if(! $belongsTo) {
156
+        if (!$belongsTo) {
157 157
             return [];
158 158
         }
159 159
         $relations = $this->getArgumentParser('relations')->parse($belongsTo);
160
-        return array_map(function($relation){
160
+        return array_map(function($relation) {
161 161
             $name = $relation['model'] ? $relation['model'] : $relation['name'];
162 162
             $index = strrpos($name, "\\");
163
-            if($index) {
163
+            if ($index) {
164 164
                 $name = substr($name, $index + 1);
165 165
             }
166 166
             return Str::snake(Str::singular($name)) . '_id';
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 
182 182
     protected function factoryFields()
183 183
     {
184
-        return array_map(function($field){
184
+        return array_map(function($field) {
185 185
             return [
186 186
                 'name' => $field['name'],
187 187
                 'type' => $field['factory']
188 188
             ];
189
-        }, array_filter($this->fields, function($field){
189
+        }, array_filter($this->fields, function($field) {
190 190
             return isset($field['factory']) && $field['factory'];
191 191
         }));
192 192
     }
Please login to merge, or discard this patch.
src/Commands/ResourcesCommand.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -135,6 +135,10 @@
 block discarded – undo
135 135
         return $string;
136 136
     }
137 137
 
138
+    /**
139
+     * @param string $old
140
+     * @param string $new
141
+     */
138 142
     protected function convertArray($list, $old, $new)
139 143
     {
140 144
         return implode($new, array_filter(explode($old, $list), function($item){
Please login to merge, or discard this patch.
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
 use Illuminate\Support\Str;
6 5
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
 
76 76
     protected function getResourceParams($modelName, $i)
77 77
     {
78
-       $i['name'] = Str::snake($modelName);
78
+        $i['name'] = Str::snake($modelName);
79 79
 
80 80
         foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){
81 81
             if(isset($i[$relation])){
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) . '_' . Str::snake($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) . '_' . Str::snake($migrationName) . '_table';
31 31
             
32 32
             $options = [
33 33
                 'name' => $i['name'],
@@ -77,34 +77,34 @@  discard block
 block discarded – undo
77 77
     {
78 78
        $i['name'] = Str::snake($modelName);
79 79
 
80
-        foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){
81
-            if(isset($i[$relation])){
80
+        foreach (['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation) {
81
+            if (isset($i[$relation])) {
82 82
                 $i[$relation] = $this->convertArray($i[$relation], ' ', ',');
83 83
             } else {
84 84
                 $i[$relation] = false;
85 85
             }
86 86
         }
87 87
 
88
-        if($i['belongsToMany']){
88
+        if ($i['belongsToMany']) {
89 89
             $relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']);
90
-            foreach ($relations as $relation){
90
+            foreach ($relations as $relation) {
91 91
                 $table = '';
92 92
 
93
-                if(! $relation['model']){
93
+                if (!$relation['model']) {
94 94
                     $table = Str::snake($relation['name']);
95 95
                 } else {
96 96
                     $names = array_reverse(explode("\\", $relation['model']));
97 97
                     $table = Str::snake($names[0]);
98 98
                 }
99 99
 
100
-                $tables = [ Str::singular($table), $i['name'] ];
100
+                $tables = [Str::singular($table), $i['name']];
101 101
                 sort($tables);
102 102
                 $this->pivotTables[] = $tables;
103 103
             }
104 104
         }
105 105
 
106 106
         $fields = [];
107
-        foreach($i['fields'] as $name => $value) {
107
+        foreach ($i['fields'] as $name => $value) {
108 108
             $value['name'] = $name;
109 109
             $fields[] = $this->serializeField($value);
110 110
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         $string = "{$name};{$schema};{$rules};{$tags}";
127 127
 
128
-        if(isset($field['factory']) && !empty($field['factory'])){
128
+        if (isset($field['factory']) && !empty($field['factory'])) {
129 129
             $string .= ';' . $field['factory'];
130 130
         }
131 131
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     protected function convertArray($list, $old, $new)
136 136
     {
137
-        return implode($new, array_filter(explode($old, $list), function($item){
137
+        return implode($new, array_filter(explode($old, $list), function($item) {
138 138
             return !empty($item);
139 139
         }));
140 140
     }
Please login to merge, or discard this patch.
src/Template/TemplateLoader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
 
20 20
 	public function load($name)
21 21
 	{
22
-		if(! isset($this->loaded[$name])){
22
+		if (!isset($this->loaded[$name])) {
23 23
 			$path = __DIR__ . "/../../templates/{$name}.wnt";
24 24
 			try {
25 25
 				$this->loaded[$name] = $this->fs->get($path);
26
-			} catch(\Exception $e) {
26
+			} catch (\Exception $e) {
27 27
 				throw new TemplateException("Unable to read the file '{$path}'");
28 28
 			}
29 29
 		}
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@
 block discarded – undo
7 7
 
8 8
 class TemplateLoader {
9 9
 	
10
-	protected $fs;
10
+    protected $fs;
11 11
 
12
-	protected $loaded;
12
+    protected $loaded;
13 13
 
14
-	public function __construct(Filesystem $fs)
15
-	{
16
-		$this->fs = $fs;
17
-		$this->loaded = [];
18
-	}
14
+    public function __construct(Filesystem $fs)
15
+    {
16
+        $this->fs = $fs;
17
+        $this->loaded = [];
18
+    }
19 19
 
20
-	public function load($name)
21
-	{
22
-		if(! isset($this->loaded[$name])){
23
-			$path = __DIR__ . "/../../templates/{$name}.wnt";
24
-			try {
25
-				$this->loaded[$name] = $this->fs->get($path);
26
-			} catch(\Exception $e) {
27
-				throw new TemplateException("Unable to read the file '{$path}'");
28
-			}
29
-		}
30
-		return new Template($this, $this->loaded[$name]);
31
-	}
20
+    public function load($name)
21
+    {
22
+        if(! isset($this->loaded[$name])){
23
+            $path = __DIR__ . "/../../templates/{$name}.wnt";
24
+            try {
25
+                $this->loaded[$name] = $this->fs->get($path);
26
+            } catch(\Exception $e) {
27
+                throw new TemplateException("Unable to read the file '{$path}'");
28
+            }
29
+        }
30
+        return new Template($this, $this->loaded[$name]);
31
+    }
32 32
 
33 33
 }
Please login to merge, or discard this patch.
src/Template/Template.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function with($data = [])
35 35
 	{
36
-		if($data)
36
+		if ($data)
37 37
 			$this->dirty = true;
38 38
 		foreach ($data as $key => $value) {
39 39
 			$this->data[$key] = $value;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 	public function get()
45 45
 	{
46
-		if($this->dirty){
46
+		if ($this->dirty) {
47 47
 			$this->compile();
48 48
 			$this->dirty = false;
49 49
 		}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	public function compile()
54 54
 	{
55 55
 		$this->compiled = $this->text;
56
-		foreach($this->data as $key => $value){
56
+		foreach ($this->data as $key => $value) {
57 57
 			$this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled);
58 58
 		}
59 59
 		return $this;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,9 @@
 block discarded – undo
33 33
 
34 34
 	public function with($data = [])
35 35
 	{
36
-		if($data)
37
-			$this->dirty = true;
36
+		if($data) {
37
+					$this->dirty = true;
38
+		}
38 39
 		foreach ($data as $key => $value) {
39 40
 			$this->data[$key] = $value;
40 41
 		}
Please login to merge, or discard this patch.
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -5,58 +5,58 @@
 block discarded – undo
5 5
 
6 6
 class Template {
7 7
 
8
-	protected $loader;
9
-
10
-	protected $text;
11
-
12
-	protected $data;
13
-
14
-	protected $compiled;
15
-
16
-	protected $dirty;
17
-
18
-	public function __construct(TemplateLoader $loader, $text)
19
-	{
20
-		$this->loader = $loader;
21
-		$this->text = $text;
22
-		$this->compiled = '';
23
-		$this->data = [];
24
-		$this->dirty = true;
25
-	}
26
-
27
-	public function clean()
28
-	{
29
-		$this->data = [];
30
-		$this->dirty = false;
31
-		return $this;
32
-	}
33
-
34
-	public function with($data = [])
35
-	{
36
-		if($data)
37
-			$this->dirty = true;
38
-		foreach ($data as $key => $value) {
39
-			$this->data[$key] = $value;
40
-		}
41
-		return $this;
42
-	}
43
-
44
-	public function get()
45
-	{
46
-		if($this->dirty){
47
-			$this->compile();
48
-			$this->dirty = false;
49
-		}
50
-		return $this->compiled;
51
-	}
52
-
53
-	public function compile()
54
-	{
55
-		$this->compiled = $this->text;
56
-		foreach($this->data as $key => $value){
57
-			$this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled);
58
-		}
59
-		return $this;
60
-	}	
8
+    protected $loader;
9
+
10
+    protected $text;
11
+
12
+    protected $data;
13
+
14
+    protected $compiled;
15
+
16
+    protected $dirty;
17
+
18
+    public function __construct(TemplateLoader $loader, $text)
19
+    {
20
+        $this->loader = $loader;
21
+        $this->text = $text;
22
+        $this->compiled = '';
23
+        $this->data = [];
24
+        $this->dirty = true;
25
+    }
26
+
27
+    public function clean()
28
+    {
29
+        $this->data = [];
30
+        $this->dirty = false;
31
+        return $this;
32
+    }
33
+
34
+    public function with($data = [])
35
+    {
36
+        if($data)
37
+            $this->dirty = true;
38
+        foreach ($data as $key => $value) {
39
+            $this->data[$key] = $value;
40
+        }
41
+        return $this;
42
+    }
43
+
44
+    public function get()
45
+    {
46
+        if($this->dirty){
47
+            $this->compile();
48
+            $this->dirty = false;
49
+        }
50
+        return $this->compiled;
51
+    }
52
+
53
+    public function compile()
54
+    {
55
+        $this->compiled = $this->text;
56
+        foreach($this->data as $key => $value){
57
+            $this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled);
58
+        }
59
+        return $this;
60
+    }	
61 61
 
62 62
 }
Please login to merge, or discard this patch.
src/Commands/ControllerRestActionsCommand.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@
 block discarded – undo
3 3
 
4 4
 class ControllerRestActionsCommand extends BaseCommand {
5 5
 
6
-	protected $signature = 'wn:controller:rest-actions
6
+    protected $signature = 'wn:controller:rest-actions
7 7
 		{--force= : override the existing files}';
8 8
 
9
-	protected $description = 'Generates REST actions trait to use into controllers';
9
+    protected $description = 'Generates REST actions trait to use into controllers';
10 10
 
11 11
     public function handle()
12 12
     {
Please login to merge, or discard this patch.
src/Commands/SeederCommand.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@
 block discarded – undo
3 3
 
4 4
 class SeederCommand extends BaseCommand {
5 5
 
6
-	protected $signature = 'wn:seeder
6
+    protected $signature = 'wn:seeder
7 7
         {model : full qualified name of the model.}
8 8
         {--count=10 : number of elements to add in database.}
9 9
         {--force= : override the existing files}
10 10
     ';
11 11
 
12
-	protected $description = 'Generates a seeder';
12
+    protected $description = 'Generates a seeder';
13 13
 
14 14
     public function handle()
15 15
     {
Please login to merge, or discard this patch.