@@ -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(), |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected function setArguments(): array |
28 | 28 | { |
29 | - return []; |
|
29 | + return [ ]; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -36,6 +36,6 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected function setOptions() :array |
38 | 38 | { |
39 | - return []; |
|
39 | + return [ ]; |
|
40 | 40 | } |
41 | 41 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function getNamespace(): ?string |
64 | 64 | { |
65 | - return $this->getStub()->getOptions()["NAMESPACE"] ?? null; |
|
65 | + return $this->getStub()->getOptions()[ "NAMESPACE" ] ?? null; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getClassName(): ?string |
72 | 72 | { |
73 | - return $this->getStub()->getOptions()["CLASS"] ?? null; |
|
73 | + return $this->getStub()->getOptions()[ "CLASS" ] ?? null; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getModule(): string |
80 | 80 | { |
81 | - return $this->getStub()->getOptions()["MODULE"]; |
|
81 | + return $this->getStub()->getOptions()[ "MODULE" ]; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | |
76 | 76 | protected function getFileName() :string |
77 | 77 | { |
78 | - return strtolower(Str::plural($this->getModuleName())).'.'.$this->getVersion() . '.php'; |
|
78 | + return strtolower(Str::plural($this->getModuleName())).'.'.$this->getVersion().'.php'; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | protected function setOptions(): array |
66 | 66 | { |
67 | 67 | return [ |
68 | - ['mongo', null, InputOption::VALUE_OPTIONAL, 'Mongo model.', false], |
|
69 | - ['migration', null, InputOption::VALUE_OPTIONAL, 'Create migration for the model.', true], |
|
68 | + [ 'mongo', null, InputOption::VALUE_OPTIONAL, 'Mongo model.', false ], |
|
69 | + [ 'migration', null, InputOption::VALUE_OPTIONAL, 'Create migration for the model.', true ], |
|
70 | 70 | ]; |
71 | 71 | } |
72 | 72 | |
73 | - protected function handleMongoOption($shortcut, $type, $question, $default){ |
|
73 | + protected function handleMongoOption($shortcut, $type, $question, $default) { |
|
74 | 74 | return $this->confirm('Is this model for a mongodb database?', $default); |
75 | 75 | } |
76 | 76 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return $this->getOption('mongo'); |
80 | 80 | } |
81 | 81 | |
82 | - protected function handleMigrationOption($shortcut, $type, $question, $default){ |
|
82 | + protected function handleMigrationOption($shortcut, $type, $question, $default) { |
|
83 | 83 | return $this->confirm('Do you want to create a migration for this model?', $default); |
84 | 84 | } |
85 | 85 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | if ($this->needsMigration()) { |
94 | 94 | if ($this->isMongoModel()) { |
95 | 95 | GeneratorManager::module($this->getModuleName(), $this->isOverwriteable())->createMigration( |
96 | - "Create" . ucfirst($this->getClassName()) . "Collection", |
|
96 | + "Create".ucfirst($this->getClassName())."Collection", |
|
97 | 97 | strtolower(split_caps_to_underscore(Str::plural($this->getClassName()))), |
98 | 98 | true); |
99 | 99 | } else { |
100 | 100 | GeneratorManager::module($this->getModuleName(), $this->isOverwriteable())->createMigration( |
101 | - "Create" . ucfirst($this->getClassName() . "Table"), |
|
101 | + "Create".ucfirst($this->getClassName()."Table"), |
|
102 | 102 | strtolower(split_caps_to_underscore(Str::plural($this->getClassName()))), |
103 | 103 | false); |
104 | 104 | } |
@@ -18,11 +18,11 @@ |
||
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 | } |
@@ -27,13 +27,13 @@ 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 | |
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 |
||
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 |
||
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 |
||
71 | 71 | */ |
72 | 72 | protected function setOptions() :array |
73 | 73 | { |
74 | - return []; |
|
74 | + return [ ]; |
|
75 | 75 | } |
76 | 76 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $moduleName = "User"; |
88 | 88 | $this->getModuleGenerator($moduleName)->createFactory("User"); |
89 | 89 | |
90 | - $expectedFileName = Larapi::getModule($moduleName)->getFactories()->getPath() . '/UserFactory.php'; |
|
90 | + $expectedFileName = Larapi::getModule($moduleName)->getFactories()->getPath().'/UserFactory.php'; |
|
91 | 91 | $expectedStubName = "factory.stub"; |
92 | 92 | $expectedStubOptions = [ |
93 | 93 | 'CLASS' => 'UserFactory', |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $moduleName = "User"; |
110 | 110 | $this->getModuleGenerator($moduleName)->createController("UserController"); |
111 | 111 | |
112 | - $expectedFileName = Larapi::getModule($moduleName)->getControllers()->getPath() . '/UserController.php'; |
|
112 | + $expectedFileName = Larapi::getModule($moduleName)->getControllers()->getPath().'/UserController.php'; |
|
113 | 113 | $expectedStubName = "controller.stub"; |
114 | 114 | $expectedStubOptions = [ |
115 | 115 | 'CLASS' => 'UserController', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $moduleName = "User"; |
131 | 131 | $this->getModuleGenerator($moduleName)->createListener("SendWelcomeMail", "UserRegisteredEvent"); |
132 | 132 | |
133 | - $expectedFileName = Larapi::getModule($moduleName)->getListeners()->getPath() . '/SendWelcomeMail.php'; |
|
133 | + $expectedFileName = Larapi::getModule($moduleName)->getListeners()->getPath().'/SendWelcomeMail.php'; |
|
134 | 134 | $expectedStubName = "listener.stub"; |
135 | 135 | $expectedStubOptions = [ |
136 | 136 | 'CLASS' => 'SendWelcomeMail', |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $fileName = "RandomUserJob"; |
165 | 165 | $this->getModuleGenerator($moduleName)->createJob($fileName, false); |
166 | 166 | |
167 | - $expectedFileName = Larapi::getModule($moduleName)->getJobs()->getPath() . "/$fileName.php"; |
|
167 | + $expectedFileName = Larapi::getModule($moduleName)->getJobs()->getPath()."/$fileName.php"; |
|
168 | 168 | $expectedStubName = "job-queued.stub"; |
169 | 169 | $expectedStubOptions = [ |
170 | 170 | 'NAMESPACE' => 'Modules\User\Jobs', |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | $this->getModuleGenerator($moduleName)->createCommand($fileName, $commandName); |
200 | 200 | |
201 | - $expectedFileName = Larapi::getModule($moduleName)->getCommands()->getPath() . "/$fileName.php"; |
|
201 | + $expectedFileName = Larapi::getModule($moduleName)->getCommands()->getPath()."/$fileName.php"; |
|
202 | 202 | $expectedStubName = "command.stub"; |
203 | 203 | $expectedStubOptions = [ |
204 | 204 | 'NAMESPACE' => 'Modules\User\Console', |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | $this->getModuleGenerator($moduleName)->createMiddleware($fileName); |
228 | 228 | |
229 | - $expectedFileName = Larapi::getModule($moduleName)->getMiddleWare()->getPath() . "/$fileName.php"; |
|
229 | + $expectedFileName = Larapi::getModule($moduleName)->getMiddleWare()->getPath()."/$fileName.php"; |
|
230 | 230 | $expectedStubName = "middleware.stub"; |
231 | 231 | $expectedStubOptions = [ |
232 | 232 | 'CLASS' => 'RandomMiddleware', |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | $this->getModuleGenerator($moduleName)->createServiceProvider($fileName); |
251 | 251 | |
252 | - $expectedFileName = Larapi::getModule($moduleName)->getServiceProviders()->getPath() . "/$fileName.php"; |
|
252 | + $expectedFileName = Larapi::getModule($moduleName)->getServiceProviders()->getPath()."/$fileName.php"; |
|
253 | 253 | $expectedStubName = "provider.stub"; |
254 | 254 | $expectedStubOptions = [ |
255 | 255 | 'NAMESPACE' => 'Modules\User\Providers', |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | $this->getModuleGenerator($moduleName)->createNotification($fileName); |
274 | 274 | |
275 | - $expectedFileName = Larapi::getModule($moduleName)->getNotifications()->getPath() . "/$fileName.php"; |
|
275 | + $expectedFileName = Larapi::getModule($moduleName)->getNotifications()->getPath()."/$fileName.php"; |
|
276 | 276 | $expectedStubName = "notification.stub"; |
277 | 277 | $expectedStubOptions = [ |
278 | 278 | 'NAMESPACE' => 'Modules\User\Notifications', |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | $moduleName = "User"; |
294 | 294 | $fileName = "Address"; |
295 | 295 | |
296 | - $this->getModuleGenerator($moduleName)->createModel($moduleName . $fileName, false, true); |
|
296 | + $this->getModuleGenerator($moduleName)->createModel($moduleName.$fileName, false, true); |
|
297 | 297 | |
298 | - $expectedFileName = Larapi::getModule($moduleName)->getModels()->getPath() . "/$moduleName$fileName.php"; |
|
298 | + $expectedFileName = Larapi::getModule($moduleName)->getModels()->getPath()."/$moduleName$fileName.php"; |
|
299 | 299 | $expectedStubName = "model.stub"; |
300 | 300 | $expectedStubOptions = [ |
301 | 301 | 'NAMESPACE' => 'Modules\User\Entities', |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | $this->getModuleGenerator($moduleName)->createPolicy($fileName); |
334 | 334 | |
335 | - $expectedFileName = Larapi::getModule($moduleName)->getPolicies()->getPath() . "/$fileName.php"; |
|
335 | + $expectedFileName = Larapi::getModule($moduleName)->getPolicies()->getPath()."/$fileName.php"; |
|
336 | 336 | $expectedStubName = "policy.stub"; |
337 | 337 | $expectedStubOptions = [ |
338 | 338 | 'NAMESPACE' => 'Modules\User\Policies', |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | $this->getModuleGenerator($moduleName)->createTransformer($fileName, $model); |
357 | 357 | |
358 | - $expectedFileName = Larapi::getModule($moduleName)->getTransformers()->getPath() . "/$fileName.php"; |
|
358 | + $expectedFileName = Larapi::getModule($moduleName)->getTransformers()->getPath()."/$fileName.php"; |
|
359 | 359 | $expectedStubName = "transformer.stub"; |
360 | 360 | $expectedStubOptions = [ |
361 | 361 | 'NAMESPACE' => 'Modules\User\Transformers', |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | $this->getModuleGenerator($moduleName)->createTest($fileName, 'unit'); |
381 | 381 | |
382 | - $expectedFileName = Larapi::getModule($moduleName)->getTests()->getPath() . "/$fileName.php"; |
|
382 | + $expectedFileName = Larapi::getModule($moduleName)->getTests()->getPath()."/$fileName.php"; |
|
383 | 383 | $expectedStubName = "unit-test.stub"; |
384 | 384 | $expectedStubOptions = [ |
385 | 385 | 'NAMESPACE' => 'Modules\User\Tests', |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | $this->getModuleGenerator($moduleName)->createRequest($fileName); |
404 | 404 | |
405 | - $expectedFileName = Larapi::getModule($moduleName)->getRequests()->getPath() . "/$fileName.php"; |
|
405 | + $expectedFileName = Larapi::getModule($moduleName)->getRequests()->getPath()."/$fileName.php"; |
|
406 | 406 | $expectedStubName = "request.stub"; |
407 | 407 | $expectedStubOptions = [ |
408 | 408 | 'NAMESPACE' => 'Modules\User\Http\Requests', |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | |
425 | 425 | $this->getModuleGenerator($moduleName)->createRule($fileName); |
426 | 426 | |
427 | - $expectedFileName = Larapi::getModule($moduleName)->getRules()->getPath() . "/$fileName.php"; |
|
427 | + $expectedFileName = Larapi::getModule($moduleName)->getRules()->getPath()."/$fileName.php"; |
|
428 | 428 | $expectedStubName = "rule.stub"; |
429 | 429 | $expectedStubOptions = [ |
430 | 430 | 'NAMESPACE' => 'Modules\User\Rules', |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | |
447 | 447 | $this->getModuleGenerator($moduleName)->createSeeder($fileName); |
448 | 448 | |
449 | - $expectedFileName = Larapi::getModule($moduleName)->getSeeders()->getPath() . "/$fileName.php"; |
|
449 | + $expectedFileName = Larapi::getModule($moduleName)->getSeeders()->getPath()."/$fileName.php"; |
|
450 | 450 | $expectedStubName = "seeder.stub"; |
451 | 451 | $expectedStubOptions = [ |
452 | 452 | 'NAMESPACE' => 'Modules\User\Database\Seeders', |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | public function testCreateRoute() |
465 | 465 | { |
466 | 466 | $moduleName = "Demo"; |
467 | - $routename = strtolower(Str::plural($moduleName)) . '.v1'; |
|
467 | + $routename = strtolower(Str::plural($moduleName)).'.v1'; |
|
468 | 468 | |
469 | 469 | $this->getModuleGenerator($moduleName)->createRoute(); |
470 | 470 | |
471 | - $expectedFileName = Larapi::getModule($moduleName)->getRoutes()->getPath() . "/$routename.php"; |
|
471 | + $expectedFileName = Larapi::getModule($moduleName)->getRoutes()->getPath()."/$routename.php"; |
|
472 | 472 | $expectedStubName = "route.stub"; |
473 | 473 | $expectedStubOptions = [ |
474 | 474 | 'MODULE_NAME' => 'Demo', |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | $this->getModuleGenerator($moduleName)->createComposer(); |
492 | 492 | |
493 | - $expectedFileName = Larapi::getModule($moduleName)->getPath() . "/composer.json"; |
|
493 | + $expectedFileName = Larapi::getModule($moduleName)->getPath()."/composer.json"; |
|
494 | 494 | $expectedStubName = "composer.stub"; |
495 | 495 | $expectedStubOptions = [ |
496 | 496 | 'LOWER_MODULE_NAME' => 'demo', |
@@ -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()) { |