Passed
Push — master ( 624a9a...4c85b9 )
by Arthur
36:47
created
src/Foundation/Generator/Events/ModelGeneratedEvent.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
  */
19 19
 class ModelGeneratedEvent extends ResourceGeneratedEvent
20 20
 {
21
-    public function isMongoModel(){
22
-        return $this->getStub()->getOptions()['MONGO'];
21
+    public function isMongoModel() {
22
+        return $this->getStub()->getOptions()[ 'MONGO' ];
23 23
     }
24 24
 
25
-    public function includesMigration(){
26
-        return $this->getStub()->getOptions()['MIGRATION'];
25
+    public function includesMigration() {
26
+        return $this->getStub()->getOptions()[ 'MIGRATION' ];
27 27
     }
28 28
 }
Please login to merge, or discard this patch.
src/Foundation/Generator/Abstracts/ClassGeneratorCommand.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
     protected function setArguments() :array
28 28
     {
29 29
         return [
30
-            ['name', InputArgument::OPTIONAL, 'The name of the ' . $this->getGeneratorName() . '.']
30
+            [ 'name', InputArgument::OPTIONAL, 'The name of the '.$this->getGeneratorName().'.' ]
31 31
         ];
32 32
     }
33 33
 
34 34
     protected function handleNameArgument()
35 35
     {
36
-        return $this->ask('Specify the name of the ' . $this->getGeneratorName() . '.');
36
+        return $this->ask('Specify the name of the '.$this->getGeneratorName().'.');
37 37
     }
38 38
 
39 39
     /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected function getFileName() :string
43 43
     {
44
-        return $this->getClassName() . '.php';
44
+        return $this->getClassName().'.php';
45 45
     }
46 46
 
47 47
     /**
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function getClassNamespace(): string
54 54
     {
55
-        return $this->getModule()->getNamespace() . str_replace('/', '\\', $this->filePath);
55
+        return $this->getModule()->getNamespace().str_replace('/', '\\', $this->filePath);
56 56
     }
57 57
 
58
-    protected function getClassName(){
58
+    protected function getClassName() {
59 59
         $className = $this->getArgument('name');
60
-        if($className===null){
60
+        if ($className === null) {
61 61
             $this->error('class name not specified');
62
-            throw new \Exception('Name of ' . $this->getGeneratorName() . ' not set.');
62
+            throw new \Exception('Name of '.$this->getGeneratorName().' not set.');
63 63
         }
64 64
         return $className;
65 65
     }
@@ -71,6 +71,6 @@  discard block
 block discarded – undo
71 71
      */
72 72
     protected function setOptions() :array
73 73
     {
74
-        return [];
74
+        return [ ];
75 75
     }
76 76
 }
Please login to merge, or discard this patch.
src/Foundation/Policies/OwnershipPolicy.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
      * @param $ability
101 101
      *
102 102
      * @return bool|null
103
-    */
103
+     */
104 104
     public function before($user, $ability)
105 105
     {
106 106
         if ($user->isAdmin()) {
Please login to merge, or discard this patch.
src/Foundation/Generator/Commands/FactoryMakeCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     protected function getClassName(): string
55 55
     {
56
-        return $this->getModelName() . 'Factory';
56
+        return $this->getModelName().'Factory';
57 57
     }
58 58
 
59 59
     protected function stubOptions(): array
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         return [
62 62
             'CLASS' => $this->getClassName(),
63 63
             'MODEL' => $this->getModelName(),
64
-            'MODEL_NAMESPACE' => $this->getModule()->getNamespace() . '\\' . 'Entities' . '\\' . $this->getModelName(),
64
+            'MODEL_NAMESPACE' => $this->getModule()->getNamespace().'\\'.'Entities'.'\\'.$this->getModelName(),
65 65
         ];
66 66
     }
67 67
 
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
     protected function setOptions(): array
74 74
     {
75 75
         return [
76
-            ['model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the factory.', null],
76
+            [ 'model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the factory.', null ],
77 77
         ];
78 78
     }
79 79
 
80 80
     protected function handleModelOption($shortcut, $type, $question, $default)
81 81
     {
82
-        return $this->anticipate('For what model would you like to generate a factory?', Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension(), Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension()[0] ?? "");
82
+        return $this->anticipate('For what model would you like to generate a factory?', Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension(), Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension()[ 0 ] ?? "");
83 83
     }
84 84
 
85 85
     protected function getModelName() :string
Please login to merge, or discard this patch.
src/Foundation/Generator/Commands/ModuleMakeCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     protected function getArguments()
53 53
     {
54 54
         return [
55
-            ['name', InputArgument::REQUIRED, 'The name of the module that will be created.'],
55
+            [ 'name', InputArgument::REQUIRED, 'The name of the module that will be created.' ],
56 56
         ];
57 57
     }
58 58
 }
Please login to merge, or discard this patch.
src/Foundation/Generator/Commands/TransformerMakeCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     protected function setOptions() :array
72 72
     {
73 73
         return [
74
-            ['model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the transformer.', null],
74
+            [ 'model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the transformer.', null ],
75 75
         ];
76 76
     }
77 77
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         return $this->getOption("model");
81 81
     }
82 82
 
83
-    protected function handleModelOption(){
83
+    protected function handleModelOption() {
84 84
         return $this->anticipate('For what model would you like to generate a transformer?', Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension(), $this->getModuleName());
85 85
     }
86 86
 }
Please login to merge, or discard this patch.
src/Foundation/Generator/Factories/ModuleFactory.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @var array
64 64
      */
65
-    protected $pipeline = [];
65
+    protected $pipeline = [ ];
66 66
 
67 67
     /**
68 68
      * The constructor.
@@ -78,17 +78,17 @@  discard block
 block discarded – undo
78 78
     private function createModule($moduleName): Module
79 79
     {
80 80
         $moduleName = Str::studly($moduleName);
81
-        $path = Larapi::getModulesBasePath() . '/' . $moduleName;
81
+        $path = Larapi::getModulesBasePath().'/'.$moduleName;
82 82
         if (file_exists($path)) {
83 83
             throw new FileAlreadyExistException("Module exists already. Please remove the directory first");
84 84
         }
85
-        return new Module($moduleName, Larapi::getModulesBasePath() . '/' . $moduleName);
85
+        return new Module($moduleName, Larapi::getModulesBasePath().'/'.$moduleName);
86 86
     }
87 87
 
88 88
     public function __call($name, $arguments)
89 89
     {
90 90
         if (Str::startsWith($name, 'add'))
91
-            $this->pipeline[] = [
91
+            $this->pipeline[ ] = [
92 92
                 "name" => Str::replaceFirst('add', '', $name),
93 93
                 "arguments" => $arguments
94 94
             ];
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
     {
100 100
         foreach ($this->pipeline as $command) {
101 101
             $manager = GeneratorManager::module($this->getModule()->getName());
102
-            $method = 'create' . $command['name'];
103
-            call_user_func_array(array($manager, $method), $command['arguments']);
102
+            $method = 'create'.$command[ 'name' ];
103
+            call_user_func_array(array($manager, $method), $command[ 'arguments' ]);
104 104
         }
105 105
     }
106 106
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,11 +87,12 @@
 block discarded – undo
87 87
 
88 88
     public function __call($name, $arguments)
89 89
     {
90
-        if (Str::startsWith($name, 'add'))
91
-            $this->pipeline[] = [
90
+        if (Str::startsWith($name, 'add')) {
91
+                    $this->pipeline[] = [
92 92
                 "name" => Str::replaceFirst('add', '', $name),
93 93
                 "arguments" => $arguments
94 94
             ];
95
+        }
95 96
 
96 97
     }
97 98
 
Please login to merge, or discard this patch.
src/Foundation/Generator/Abstracts/AbstractGeneratorCommand.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @var array
57 57
      */
58
-    protected $optionData = [];
58
+    protected $optionData = [ ];
59 59
 
60 60
     /**
61 61
      * The data that is inputted from the arguments.
62 62
      *
63 63
      * @var array
64 64
      */
65
-    protected $argumentData = [];
65
+    protected $argumentData = [ ];
66 66
 
67 67
     public function handle()
68 68
     {
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $this->beforeGeneration();
82 82
 
83 83
         if ($this->event === null)
84
-            throw new Exception("No Generator event specified on " . static::class);
84
+            throw new Exception("No Generator event specified on ".static::class);
85 85
 
86 86
         event(new $this->event($path, $stub));
87 87
         $this->info("Created : {$path}");
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     protected function getDestinationFilePath(): string
101 101
     {
102
-        return $this->getModule()->getPath() . $this->filePath . '/' . $this->getFileName();
102
+        return $this->getModule()->getPath().$this->filePath.'/'.$this->getFileName();
103 103
     }
104 104
 
105 105
     /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     final protected function getOptions()
146 146
     {
147 147
         $options = $this->setOptions();
148
-        $options[] = ['overwrite', null, InputOption::VALUE_NONE, 'Overwrite this file if it already exists?'];
148
+        $options[ ] = [ 'overwrite', null, InputOption::VALUE_NONE, 'Overwrite this file if it already exists?' ];
149 149
         return $options;
150 150
     }
151 151
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     final protected function getArguments()
158 158
     {
159 159
         return array_merge([
160
-            ['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
160
+            [ 'module', InputArgument::OPTIONAL, 'The name of module will be used.' ],
161 161
         ],
162 162
             $this->setArguments());
163 163
     }
@@ -194,19 +194,19 @@  discard block
 block discarded – undo
194 194
     protected function handleOptions()
195 195
     {
196 196
         foreach ($this->getOptions() as $option) {
197
-            $method = 'handle' . ucfirst(strtolower($option[0])) . 'Option';
197
+            $method = 'handle'.ucfirst(strtolower($option[ 0 ])).'Option';
198 198
             $originalInput = $this->getOriginalOptionInput();
199
-            if (isset($originalInput[$option[0]])) {
200
-                $this->optionData[$option[0]] = $originalInput[$option[0]];
199
+            if (isset($originalInput[ $option[ 0 ] ])) {
200
+                $this->optionData[ $option[ 0 ] ] = $originalInput[ $option[ 0 ] ];
201 201
             } else {
202
-                $this->optionData[$option[0]] = method_exists($this, $method) ? $this->$method($option[1], $option[2], $option[3], $option[4] ?? null) : $this->option($option[0]);
202
+                $this->optionData[ $option[ 0 ] ] = method_exists($this, $method) ? $this->$method($option[ 1 ], $option[ 2 ], $option[ 3 ], $option[ 4 ] ?? null) : $this->option($option[ 0 ]);
203 203
             }
204 204
         }
205 205
     }
206 206
 
207 207
     protected function handleModuleArgument()
208 208
     {
209
-        return $this->anticipate('For what module would you like to generate a ' . $this->getGeneratorName() . '.', Larapi::getModuleNames());
209
+        return $this->anticipate('For what module would you like to generate a '.$this->getGeneratorName().'.', Larapi::getModuleNames());
210 210
     }
211 211
 
212 212
     protected function getModuleName()
@@ -222,24 +222,24 @@  discard block
 block discarded – undo
222 222
     protected function handleArguments()
223 223
     {
224 224
         foreach ($this->getArguments() as $argument) {
225
-            $method = 'handle' . ucfirst(strtolower($argument[0])) . 'Argument';
225
+            $method = 'handle'.ucfirst(strtolower($argument[ 0 ])).'Argument';
226 226
             $originalInput = $this->getOriginalArgumentInput();
227
-            if (isset($originalInput[$argument[0]])) {
228
-                $this->argumentData[$argument[0]] = $originalInput[$argument[0]];
227
+            if (isset($originalInput[ $argument[ 0 ] ])) {
228
+                $this->argumentData[ $argument[ 0 ] ] = $originalInput[ $argument[ 0 ] ];
229 229
             } else {
230
-                $this->argumentData[$argument[0]] = method_exists($this, $method) ? $this->$method($argument[1], $argument[2], $argument[3] ?? null) : $this->option($argument[0]);
230
+                $this->argumentData[ $argument[ 0 ] ] = method_exists($this, $method) ? $this->$method($argument[ 1 ], $argument[ 2 ], $argument[ 3 ] ?? null) : $this->option($argument[ 0 ]);
231 231
             }
232 232
         }
233 233
     }
234 234
 
235 235
     protected function getArgument(string $argument)
236 236
     {
237
-        return $this->argumentData[$argument];
237
+        return $this->argumentData[ $argument ];
238 238
     }
239 239
 
240 240
     protected function getOption(string $name)
241 241
     {
242
-        return $this->optionData[$name];
242
+        return $this->optionData[ $name ];
243 243
     }
244 244
 
245 245
     private function getOriginalOptionInput()
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $key = str_replace('get', '', $method);
264 264
         if (array_key_exists(strtolower($method), $this->optionData))
265
-            return $this->optionData[$key];
265
+            return $this->optionData[ $key ];
266 266
     }
267 267
 
268 268
     protected function handleOverwriteOption($shortcut, $type, $question, $default)
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,8 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
         $this->beforeGeneration();
82 82
 
83
-        if ($this->event === null)
84
-            throw new Exception("No Generator event specified on " . static::class);
83
+        if ($this->event === null) {
84
+                    throw new Exception("No Generator event specified on " . static::class);
85
+        }
85 86
 
86 87
         event(new $this->event($path, $stub));
87 88
         $this->info("Created : {$path}");
@@ -261,8 +262,9 @@  discard block
 block discarded – undo
261 262
     public function __call($method, $parameters)
262 263
     {
263 264
         $key = str_replace('get', '', $method);
264
-        if (array_key_exists(strtolower($method), $this->optionData))
265
-            return $this->optionData[$key];
265
+        if (array_key_exists(strtolower($method), $this->optionData)) {
266
+                    return $this->optionData[$key];
267
+        }
266 268
     }
267 269
 
268 270
     protected function handleOverwriteOption($shortcut, $type, $question, $default)
Please login to merge, or discard this patch.
src/Foundation/Tests/ModuleGeneratorTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $pipeline = $this->moduleFactory->getPipeline();
57 57
 
58 58
         $this->assertIsArray($pipeline);
59
-        $this->assertEquals('Controller', $pipeline[0]['name']);
59
+        $this->assertEquals('Controller', $pipeline[ 0 ][ 'name' ]);
60 60
     }
61 61
 
62 62
     public function testModuleGeneration()
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
         $events = $this->getDispatchedEvents(TestGeneratedEvent::class);
114 114
         $this->assertNotEmpty($events);
115 115
 
116
-        $this->assertEquals($events[0]->getClassName(), "AServiceTest");
117
-        $this->assertEquals($events[0]->getType(), "service");
116
+        $this->assertEquals($events[ 0 ]->getClassName(), "AServiceTest");
117
+        $this->assertEquals($events[ 0 ]->getType(), "service");
118 118
 
119
-        $this->assertEquals($events[1]->getClassName(), "AHttpTest");
120
-        $this->assertEquals($events[1]->getType(), "http");
119
+        $this->assertEquals($events[ 1 ]->getClassName(), "AHttpTest");
120
+        $this->assertEquals($events[ 1 ]->getType(), "http");
121 121
 
122
-        $this->assertEquals($events[2]->getClassName(), "AUnitTest");
123
-        $this->assertEquals($events[2]->getType(), "unit");
122
+        $this->assertEquals($events[ 2 ]->getClassName(), "AUnitTest");
123
+        $this->assertEquals($events[ 2 ]->getType(), "unit");
124 124
 
125 125
         Event::assertDispatched(CommandGeneratedEvent::class, 1);
126 126
 
Please login to merge, or discard this patch.