@@ -52,7 +52,7 @@ |
||
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 | } |
@@ -71,7 +71,7 @@ discard block |
||
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 |
||
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 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function alterOptions($options) |
60 | 60 | { |
61 | - $options['module'] = Str::studly($this->moduleName); |
|
61 | + $options[ 'module' ] = Str::studly($this->moduleName); |
|
62 | 62 | if ($this->overwrite) |
63 | - $options['--overwrite'] = null; |
|
63 | + $options[ '--overwrite' ] = null; |
|
64 | 64 | return $options; |
65 | 65 | } |
66 | 66 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function createComposer() |
240 | 240 | { |
241 | - $this->call('composer', []); |
|
241 | + $this->call('composer', [ ]); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -62,7 +62,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -55,14 +55,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) |
@@ -56,7 +56,7 @@ discard block |
||
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 |
||
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 |
@@ -83,7 +83,7 @@ |
||
83 | 83 | |
84 | 84 | public function getStubOption(string $option) |
85 | 85 | { |
86 | - return $this->getStub()->getOptions()[strtoupper($option)] ?? null; |
|
86 | + return $this->getStub()->getOptions()[ strtoupper($option) ] ?? null; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | } |
@@ -18,10 +18,10 @@ |
||
18 | 18 | */ |
19 | 19 | class TransformerGeneratedEvent extends ResourceGeneratedEvent |
20 | 20 | { |
21 | - public function getModel(){ |
|
21 | + public function getModel() { |
|
22 | 22 | return $this->getStubOption("model"); |
23 | 23 | } |
24 | - public function getModelNamespace(){ |
|
24 | + public function getModelNamespace() { |
|
25 | 25 | return $this->getStubOption("model_namespace"); |
26 | 26 | } |
27 | 27 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | return $this->getStubOption("table"); |
23 | 23 | } |
24 | 24 | |
25 | - public function isMongoMigration(){ |
|
25 | + public function isMongoMigration() { |
|
26 | 26 | return $this->getStubOption("mongo"); |
27 | 27 | } |
28 | 28 | } |