@@ -100,7 +100,7 @@ |
||
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()) { |
@@ -53,7 +53,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -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 | } |
@@ -40,37 +40,37 @@ |
||
40 | 40 | /** |
41 | 41 | * |
42 | 42 | */ |
43 | - public function generate(){ |
|
43 | + public function generate() { |
|
44 | 44 | |
45 | 45 | $this->moduleFactory->addModel($this->moduleName, true, true); |
46 | 46 | |
47 | - $this->moduleFactory->addService($this->moduleName . 'Service'); |
|
47 | + $this->moduleFactory->addService($this->moduleName.'Service'); |
|
48 | 48 | |
49 | - $this->moduleFactory->addController($this->moduleName . "Controller"); |
|
49 | + $this->moduleFactory->addController($this->moduleName."Controller"); |
|
50 | 50 | |
51 | - $this->moduleFactory->addTest($this->moduleName . 'ServiceTest', 'service'); |
|
52 | - $this->moduleFactory->addTest($this->moduleName . 'HttpTest', 'http'); |
|
53 | - $this->moduleFactory->addTest($this->moduleName . 'UnitTest', 'unit'); |
|
51 | + $this->moduleFactory->addTest($this->moduleName.'ServiceTest', 'service'); |
|
52 | + $this->moduleFactory->addTest($this->moduleName.'HttpTest', 'http'); |
|
53 | + $this->moduleFactory->addTest($this->moduleName.'UnitTest', 'unit'); |
|
54 | 54 | |
55 | - $this->moduleFactory->addEvent($this->moduleName . 'WasCreatedEvent'); |
|
56 | - $this->moduleFactory->addEvent($this->moduleName . 'WasUpdatedEvent'); |
|
57 | - $this->moduleFactory->addEvent($this->moduleName . 'WasDeletedEvent'); |
|
55 | + $this->moduleFactory->addEvent($this->moduleName.'WasCreatedEvent'); |
|
56 | + $this->moduleFactory->addEvent($this->moduleName.'WasUpdatedEvent'); |
|
57 | + $this->moduleFactory->addEvent($this->moduleName.'WasDeletedEvent'); |
|
58 | 58 | |
59 | - $this->moduleFactory->addRequest('Find'.$this->moduleName . 'Request'); |
|
60 | - $this->moduleFactory->addRequest('Index'.$this->moduleName . 'Request'); |
|
61 | - $this->moduleFactory->addRequest('Create'.$this->moduleName . 'Request'); |
|
62 | - $this->moduleFactory->addRequest('Update'.$this->moduleName . 'Request'); |
|
63 | - $this->moduleFactory->addRequest('Delete'.$this->moduleName . 'Request'); |
|
59 | + $this->moduleFactory->addRequest('Find'.$this->moduleName.'Request'); |
|
60 | + $this->moduleFactory->addRequest('Index'.$this->moduleName.'Request'); |
|
61 | + $this->moduleFactory->addRequest('Create'.$this->moduleName.'Request'); |
|
62 | + $this->moduleFactory->addRequest('Update'.$this->moduleName.'Request'); |
|
63 | + $this->moduleFactory->addRequest('Delete'.$this->moduleName.'Request'); |
|
64 | 64 | |
65 | - $this->moduleFactory->addPermission($this->moduleName . 'Permission'); |
|
65 | + $this->moduleFactory->addPermission($this->moduleName.'Permission'); |
|
66 | 66 | |
67 | - $this->moduleFactory->addPolicy($this->moduleName . 'Policy'); |
|
67 | + $this->moduleFactory->addPolicy($this->moduleName.'Policy'); |
|
68 | 68 | |
69 | 69 | $this->moduleFactory->addFactory($this->moduleName); |
70 | 70 | |
71 | 71 | $this->moduleFactory->addTransformer($this->moduleName.'Transformer', $this->moduleName); |
72 | 72 | |
73 | - $this->moduleFactory->addServiceProvider($this->moduleName . 'ServiceProvider'); |
|
73 | + $this->moduleFactory->addServiceProvider($this->moduleName.'ServiceProvider'); |
|
74 | 74 | |
75 | 75 | $this->moduleFactory->addRoute(); |
76 | 76 |
@@ -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 | /** |
@@ -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) |
@@ -80,8 +80,9 @@ discard block |
||
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 |
||
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) |
@@ -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 |