@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | protected function setOptions(): array |
67 | 67 | { |
68 | 68 | return [ |
69 | - ['mongo', null, InputOption::VALUE_OPTIONAL, 'Mongo model.', false], |
|
70 | - ['migration', null, InputOption::VALUE_OPTIONAL, 'Create migration for the model.', true], |
|
69 | + [ 'mongo', null, InputOption::VALUE_OPTIONAL, 'Mongo model.', false ], |
|
70 | + [ 'migration', null, InputOption::VALUE_OPTIONAL, 'Create migration for the model.', true ], |
|
71 | 71 | ]; |
72 | 72 | } |
73 | 73 | |
74 | - protected function handleMongoOption($shortcut, $type, $question, $default){ |
|
74 | + protected function handleMongoOption($shortcut, $type, $question, $default) { |
|
75 | 75 | return $this->confirm('Is this model for a mongodb database?', $default); |
76 | 76 | } |
77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return $this->getOption('mongo'); |
81 | 81 | } |
82 | 82 | |
83 | - protected function handleMigrationOption($shortcut, $type, $question, $default){ |
|
83 | + protected function handleMigrationOption($shortcut, $type, $question, $default) { |
|
84 | 84 | return $this->confirm('Do you want to create a migration for this model?', $default); |
85 | 85 | } |
86 | 86 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | if ($this->needsMigration()) { |
95 | 95 | if ($this->isMongoModel()) { |
96 | 96 | GeneratorManager::module($this->getModuleName(), $this->isOverwriteable())->createMigration( |
97 | - "Create" . ucfirst($this->getClassName()) . "Collection", |
|
97 | + "Create".ucfirst($this->getClassName())."Collection", |
|
98 | 98 | strtolower(split_caps_to_underscore(Str::plural($this->getClassName()))), |
99 | 99 | true); |
100 | 100 | } else { |
101 | 101 | GeneratorManager::module($this->getModuleName(), $this->isOverwriteable())->createMigration( |
102 | - "Create" . ucfirst($this->getClassName() . "Table"), |
|
102 | + "Create".ucfirst($this->getClassName()."Table"), |
|
103 | 103 | strtolower(split_caps_to_underscore(Str::plural($this->getClassName()))), |
104 | 104 | false); |
105 | 105 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if (strtolower($class) === strtolower($this->getModuleName())) { |
113 | 113 | return $class; |
114 | 114 | } |
115 | - return ucfirst($this->getModuleName()) . ucfirst($class); |
|
115 | + return ucfirst($this->getModuleName()).ucfirst($class); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | |
55 | 55 | protected function getModelName(): string |
56 | 56 | { |
57 | - return once(function () { |
|
58 | - return $this->option('model') ?? $this->anticipate('For what model would you like to generate a factory?', [$this->getModuleName()], $this->getModuleName()); |
|
57 | + return once(function() { |
|
58 | + return $this->option('model') ?? $this->anticipate('For what model would you like to generate a factory?', [ $this->getModuleName() ], $this->getModuleName()); |
|
59 | 59 | }); |
60 | 60 | } |
61 | 61 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | protected function setOptions() :array |
82 | 82 | { |
83 | 83 | return [ |
84 | - ['model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the factory.', null], |
|
84 | + [ 'model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the factory.', null ], |
|
85 | 85 | ]; |
86 | 86 | } |
87 | 87 | |
88 | - protected function handleCommandOption($shortcut, $type, $question, $default){ |
|
89 | - return $this->anticipate('What is the name of the model?', Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension(),Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension()[0]); |
|
88 | + protected function handleCommandOption($shortcut, $type, $question, $default) { |
|
89 | + return $this->anticipate('What is the name of the model?', Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension(), Larapi::getModule($this->getModuleName())->getModels()->getAllPhpFileNamesWithoutExtension()[ 0 ]); |
|
90 | 90 | } |
91 | 91 | } |
@@ -85,7 +85,7 @@ |
||
85 | 85 | protected function setOptions(): array |
86 | 86 | { |
87 | 87 | return [ |
88 | - ['type', $this->types, InputOption::VALUE_OPTIONAL, 'Indicates the type of the test.', $this->types[0]] |
|
88 | + [ 'type', $this->types, InputOption::VALUE_OPTIONAL, 'Indicates the type of the test.', $this->types[ 0 ] ] |
|
89 | 89 | ]; |
90 | 90 | } |
91 | 91 |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | return [ |
51 | 51 | 'NAMESPACE' => $this->getClassNamespace(), |
52 | 52 | 'CLASS' => $this->getClassName(), |
53 | - 'EVENTNAME' => $this->getModule()->getNamespace() . '\\' . 'Events' . '\\' . $this->getEventName(), |
|
53 | + 'EVENTNAME' => $this->getModule()->getNamespace().'\\'.'Events'.'\\'.$this->getEventName(), |
|
54 | 54 | 'SHORTEVENTNAME' => $this->getEventName() |
55 | 55 | ]; |
56 | 56 | } |
57 | 57 | |
58 | 58 | protected function afterGeneration(): void |
59 | 59 | { |
60 | - $this->info("don't forget to add the listener to " . $this->getEventName()); |
|
60 | + $this->info("don't forget to add the listener to ".$this->getEventName()); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | protected function setOptions(): array |
91 | 91 | { |
92 | 92 | return [ |
93 | - ['event', null, InputOption::VALUE_OPTIONAL, 'What is the name of the event that should be listened on?', null], |
|
94 | - ['queued', null, InputOption::VALUE_OPTIONAL, 'Should the listener be queued?', false], |
|
93 | + [ 'event', null, InputOption::VALUE_OPTIONAL, 'What is the name of the event that should be listened on?', null ], |
|
94 | + [ 'queued', null, InputOption::VALUE_OPTIONAL, 'Should the listener be queued?', false ], |
|
95 | 95 | ]; |
96 | 96 | } |
97 | 97 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function setOptions(): array |
69 | 69 | { |
70 | 70 | return [ |
71 | - ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null], |
|
71 | + [ 'command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null ], |
|
72 | 72 | ]; |
73 | 73 | } |
74 | 74 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return $this->getOption('command'); |
81 | 81 | } |
82 | 82 | |
83 | - protected function handleCommandOption($shortcut, $type, $question, $default){ |
|
84 | - return $this->ask('What is the name of the terminal command?',str_replace('command', '', strtolower($this->getModuleName()) . ':' . strtolower($this->getClassName()))); |
|
83 | + protected function handleCommandOption($shortcut, $type, $question, $default) { |
|
84 | + return $this->ask('What is the name of the terminal command?', str_replace('command', '', strtolower($this->getModuleName()).':'.strtolower($this->getClassName()))); |
|
85 | 85 | } |
86 | 86 | } |
@@ -58,9 +58,9 @@ |
||
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 |
@@ -59,8 +59,9 @@ |
||
59 | 59 | protected function alterOptions($options) |
60 | 60 | { |
61 | 61 | $options['module'] = Str::studly($this->moduleName); |
62 | - if ($this->overwrite) |
|
63 | - $options['--overwrite'] = null; |
|
62 | + if ($this->overwrite) { |
|
63 | + $options['--overwrite'] = null; |
|
64 | + } |
|
64 | 65 | return $options; |
65 | 66 | } |
66 | 67 |
@@ -29,8 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | public function handle(ResourceGenerationContract $event) |
31 | 31 | { |
32 | - if (file_exists($event->getFilePath())) |
|
33 | - unlink($event->getFilePath()); |
|
32 | + if (file_exists($event->getFilePath())) { |
|
33 | + unlink($event->getFilePath()); |
|
34 | + } |
|
34 | 35 | |
35 | 36 | (new FileGenerator( |
36 | 37 | $event->getFilePath(), |
@@ -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 | * @return string |
62 | 62 | */ |
63 | 63 | protected function getDestinationFilePath(): string |
64 | 64 | { |
65 | - return $this->getModule()->getPath() . $this->filePath . '/' . $this->getFileName(); |
|
65 | + return $this->getModule()->getPath().$this->filePath.'/'.$this->getFileName(); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->beforeGeneration(); |
84 | 84 | |
85 | 85 | if ($this->event === null) |
86 | - throw new Exception("No Generator event specified on " . static::class); |
|
86 | + throw new Exception("No Generator event specified on ".static::class); |
|
87 | 87 | |
88 | 88 | event(new $this->event($path, $stub)); |
89 | 89 | $this->info("Created : {$path}"); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function getFileName() |
98 | 98 | { |
99 | - return $this->getClassName() . '.php'; |
|
99 | + return $this->getClassName().'.php'; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | protected function isOverwriteable() :bool |
@@ -108,21 +108,21 @@ discard block |
||
108 | 108 | |
109 | 109 | protected function getModule(): Module |
110 | 110 | { |
111 | - return once(function () { |
|
111 | + return once(function() { |
|
112 | 112 | return Larapi::getModule($this->getModuleName()); |
113 | 113 | }); |
114 | 114 | } |
115 | 115 | |
116 | 116 | protected function getModuleName(): string |
117 | 117 | { |
118 | - return once(function () { |
|
118 | + return once(function() { |
|
119 | 119 | return Str::studly($this->askModuleName()); |
120 | 120 | }); |
121 | 121 | } |
122 | 122 | |
123 | 123 | private function askModuleName(): string |
124 | 124 | { |
125 | - $moduleName = $this->argument('module') ?? $this->anticipate('For what module would you like to generate a ' . $this->getGeneratorName() . '.', Larapi::getModuleNames()); |
|
125 | + $moduleName = $this->argument('module') ?? $this->anticipate('For what module would you like to generate a '.$this->getGeneratorName().'.', Larapi::getModuleNames()); |
|
126 | 126 | |
127 | 127 | if ($moduleName === null) { |
128 | 128 | $this->error('module not specified'); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function getClassNamespace(): string |
142 | 142 | { |
143 | - return $this->getModule()->getNamespace() . str_replace('/', '\\', $this->filePath); |
|
143 | + return $this->getModule()->getNamespace().str_replace('/', '\\', $this->filePath); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | final protected function getOptions() |
170 | 170 | { |
171 | 171 | $options = $this->setOptions(); |
172 | - $options[] = ['overwrite', null, InputOption::VALUE_NONE, 'Overwrite this file if it already exists?']; |
|
172 | + $options[ ] = [ 'overwrite', null, InputOption::VALUE_NONE, 'Overwrite this file if it already exists?' ]; |
|
173 | 173 | return $options; |
174 | 174 | } |
175 | 175 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | final protected function getArguments() |
182 | 182 | { |
183 | 183 | return array_merge([ |
184 | - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
184 | + [ 'module', InputArgument::OPTIONAL, 'The name of module will be used.' ], |
|
185 | 185 | ], |
186 | 186 | $this->setArguments()); |
187 | 187 | } |
@@ -202,17 +202,17 @@ discard block |
||
202 | 202 | |
203 | 203 | protected function getClassName(): string |
204 | 204 | { |
205 | - return once(function () { |
|
205 | + return once(function() { |
|
206 | 206 | return Str::studly($this->askClassName()); |
207 | 207 | }); |
208 | 208 | } |
209 | 209 | |
210 | 210 | private function askClassName(): string |
211 | 211 | { |
212 | - $className = $this->argument('name') ?? $this->ask('Specify the name of the ' . $this->getGeneratorName() . '.'); |
|
212 | + $className = $this->argument('name') ?? $this->ask('Specify the name of the '.$this->getGeneratorName().'.'); |
|
213 | 213 | |
214 | 214 | if ($className === null) { |
215 | - throw new \Exception('Name of ' . $this->getGeneratorName() . ' not set.'); |
|
215 | + throw new \Exception('Name of '.$this->getGeneratorName().' not set.'); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return $className; |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | protected function handleOptions() |
236 | 236 | { |
237 | 237 | foreach ($this->getOptions() as $option) { |
238 | - $method = 'handle' . ucfirst(strtolower($option[0])) . 'Option'; |
|
238 | + $method = 'handle'.ucfirst(strtolower($option[ 0 ])).'Option'; |
|
239 | 239 | $originalInput = $this->getOriginalOptionInput(); |
240 | - if (isset($originalInput[$option[0]])) { |
|
241 | - $this->optionData[$option[0]] = $originalInput[$option[0]]; |
|
240 | + if (isset($originalInput[ $option[ 0 ] ])) { |
|
241 | + $this->optionData[ $option[ 0 ] ] = $originalInput[ $option[ 0 ] ]; |
|
242 | 242 | } else { |
243 | - $this->optionData[$option[0]] = method_exists($this, $method) ? $this->$method($option[1], $option[2], $option[3], $option[4]) : $this->option($option[0]); |
|
243 | + $this->optionData[ $option[ 0 ] ] = method_exists($this, $method) ? $this->$method($option[ 1 ], $option[ 2 ], $option[ 3 ], $option[ 4 ]) : $this->option($option[ 0 ]); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | 248 | protected function getOption(string $name) |
249 | 249 | { |
250 | - return $this->optionData[$name]; |
|
250 | + return $this->optionData[ $name ]; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | private function buildInputOption($key, $shortcut, $type, $question, $default) |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } elseif ($type === InputOption::VALUE_OPTIONAL || $type === InputOption::VALUE_IS_BOOL) { |
260 | 260 | if ($type !== InputOption::VALUE_IS_BOOL && ($input = $this->option($key)) !== null) { |
261 | 261 | if (is_bool($default)) |
262 | - return (bool)$input; |
|
262 | + return (bool) $input; |
|
263 | 263 | return $input; |
264 | 264 | } else { |
265 | 265 | if ($this->isShortcutBool($shortcut)) |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | |
286 | 286 | private function isShortcutBool($shortcut) |
287 | 287 | { |
288 | - return is_bool($shortcut) || (is_array($shortcut) && is_bool($shortcut[0])); |
|
288 | + return is_bool($shortcut) || (is_array($shortcut) && is_bool($shortcut[ 0 ])); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | public function __call($method, $parameters) |
292 | 292 | { |
293 | 293 | $key = str_replace('get', '', $method); |
294 | 294 | if (array_key_exists(strtolower($method), $this->optionData)) |
295 | - return $this->optionData[$key]; |
|
295 | + return $this->optionData[ $key ]; |
|
296 | 296 | } |
297 | 297 | } |
@@ -82,8 +82,9 @@ discard block |
||
82 | 82 | |
83 | 83 | $this->beforeGeneration(); |
84 | 84 | |
85 | - if ($this->event === null) |
|
86 | - throw new Exception("No Generator event specified on " . static::class); |
|
85 | + if ($this->event === null) { |
|
86 | + throw new Exception("No Generator event specified on " . static::class); |
|
87 | + } |
|
87 | 88 | |
88 | 89 | event(new $this->event($path, $stub)); |
89 | 90 | $this->info("Created : {$path}"); |
@@ -258,16 +259,18 @@ discard block |
||
258 | 259 | return $this->option($key); |
259 | 260 | } elseif ($type === InputOption::VALUE_OPTIONAL || $type === InputOption::VALUE_IS_BOOL) { |
260 | 261 | if ($type !== InputOption::VALUE_IS_BOOL && ($input = $this->option($key)) !== null) { |
261 | - if (is_bool($default)) |
|
262 | - return (bool)$input; |
|
262 | + if (is_bool($default)) { |
|
263 | + return (bool)$input; |
|
264 | + } |
|
263 | 265 | return $input; |
264 | 266 | } else { |
265 | - if ($this->isShortcutBool($shortcut)) |
|
266 | - return $this->confirm($question, $default); |
|
267 | - else if (is_array($shortcut)) |
|
268 | - return $this->anticipate($question, $shortcut, $default); |
|
269 | - else |
|
270 | - return $this->ask($question, $default); |
|
267 | + if ($this->isShortcutBool($shortcut)) { |
|
268 | + return $this->confirm($question, $default); |
|
269 | + } else if (is_array($shortcut)) { |
|
270 | + return $this->anticipate($question, $shortcut, $default); |
|
271 | + } else { |
|
272 | + return $this->ask($question, $default); |
|
273 | + } |
|
271 | 274 | } |
272 | 275 | |
273 | 276 | } |
@@ -291,7 +294,8 @@ discard block |
||
291 | 294 | public function __call($method, $parameters) |
292 | 295 | { |
293 | 296 | $key = str_replace('get', '', $method); |
294 | - if (array_key_exists(strtolower($method), $this->optionData)) |
|
295 | - return $this->optionData[$key]; |
|
297 | + if (array_key_exists(strtolower($method), $this->optionData)) { |
|
298 | + return $this->optionData[$key]; |
|
299 | + } |
|
296 | 300 | } |
297 | 301 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $pipeline = $this->generator->getPipeline(); |
54 | 54 | |
55 | 55 | $this->assertIsArray($pipeline); |
56 | - $this->assertEquals('Controller', $pipeline[0]['name']); |
|
56 | + $this->assertEquals('Controller', $pipeline[ 0 ][ 'name' ]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public function testModuleGeneration() |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | |
63 | 63 | $this->generator->addController($controller = 'AController'); |
64 | 64 | |
65 | - $this->generator->addTest($serviceTest = 'AServiceTest', $serviceType ='service'); |
|
66 | - $this->generator->addTest($httpTest = 'AHttpTest', $httpType ='http'); |
|
67 | - $this->generator->addTest($unitTest = 'AUnitTest', $unitType ='unit'); |
|
65 | + $this->generator->addTest($serviceTest = 'AServiceTest', $serviceType = 'service'); |
|
66 | + $this->generator->addTest($httpTest = 'AHttpTest', $httpType = 'http'); |
|
67 | + $this->generator->addTest($unitTest = 'AUnitTest', $unitType = 'unit'); |
|
68 | 68 | |
69 | 69 | $this->generator->addCommand($command = 'ACommand', $commandName = 'command:dosomething'); |
70 | 70 |