@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | public function getPath() |
19 | 19 | { |
20 | - return get_foundation_path() . '/Generator/Stubs/' . $this->path; |
|
20 | + return get_foundation_path().'/Generator/Stubs/'.$this->path; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function getName() |
@@ -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 |
@@ -87,11 +87,12 @@ |
||
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 |
@@ -19,6 +19,6 @@ |
||
19 | 19 | { |
20 | 20 | public function getConsoleCommand() |
21 | 21 | { |
22 | - return $this->getStub()->getOptions()["COMMAND_NAME"]; |
|
22 | + return $this->getStub()->getOptions()[ "COMMAND_NAME" ]; |
|
23 | 23 | } |
24 | 24 | } |
@@ -19,6 +19,6 @@ |
||
19 | 19 | { |
20 | 20 | public function isSynchronous(): bool |
21 | 21 | { |
22 | - return $this->getStub()->getOptions()['sync']; |
|
22 | + return $this->getStub()->getOptions()[ 'sync' ]; |
|
23 | 23 | } |
24 | 24 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | class TestGeneratedEvent extends ResourceGeneratedEvent |
20 | 20 | { |
21 | - public function getType(){ |
|
22 | - return $this->getStub()->getOptions()['TYPE']; |
|
21 | + public function getType() { |
|
22 | + return $this->getStub()->getOptions()[ 'TYPE' ]; |
|
23 | 23 | } |
24 | 24 | } |
@@ -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 | } |
@@ -27,7 +27,7 @@ discard block |
||
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 | |
@@ -38,6 +38,6 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected function setOptions() :array |
40 | 40 | { |
41 | - return []; |
|
41 | + return [ ]; |
|
42 | 42 | } |
43 | 43 | } |