@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var File[] $files |
37 | 37 | */ |
38 | - protected $files = []; |
|
38 | + protected $files = [ ]; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * LarapiModule constructor. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $files = $this->getAllPhpFileNamesWithoutExtension(); |
61 | 61 | foreach ($files as $file) { |
62 | - $this->files[] = new File($file, $this->getPath() . '/' . $file . '.php', $this); |
|
62 | + $this->files[ ] = new File($file, $this->getPath().'/'.$file.'.php', $this); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getPath(): string |
86 | 86 | { |
87 | - return $this->module->getPath() . $this->subPath; |
|
87 | + return $this->module->getPath().$this->subPath; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getNamespace(): string |
94 | 94 | { |
95 | - return $this->module->getNamespace() . str_replace('/', '\\', $this->getSubPath()); |
|
95 | + return $this->module->getNamespace().str_replace('/', '\\', $this->getSubPath()); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getClasses(): array |
110 | 110 | { |
111 | - $classes = []; |
|
111 | + $classes = [ ]; |
|
112 | 112 | foreach ($this->getAllPhpFileNames() as $file) { |
113 | 113 | $shortClassName = str_replace('.php', '', $file); |
114 | - $class = $this->getNamespace() . '\\' . $shortClassName; |
|
114 | + $class = $this->getNamespace().'\\'.$shortClassName; |
|
115 | 115 | |
116 | 116 | if ($this->baseClass === null || instance_without_constructor($class) instanceof $this->baseClass) { |
117 | - $classes[] = $class; |
|
117 | + $classes[ ] = $class; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | return $classes; |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | public function getAllFileNames() |
132 | 132 | { |
133 | 133 | try { |
134 | - $fileNames = array_diff(scandir($this->getPath()), ['..', '.']); |
|
134 | + $fileNames = array_diff(scandir($this->getPath()), [ '..', '.' ]); |
|
135 | 135 | } catch (\ErrorException $e) { |
136 | - $fileNames = []; |
|
136 | + $fileNames = [ ]; |
|
137 | 137 | } |
138 | 138 | return $fileNames; |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function getAllPhpFileNames() |
142 | 142 | { |
143 | - $files = []; |
|
143 | + $files = [ ]; |
|
144 | 144 | foreach ($this->getAllFileNames() as $file) { |
145 | 145 | if ($this->hasPhpExtension($file)) { |
146 | - $files[] = $file; |
|
146 | + $files[ ] = $file; |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | return $files; |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | |
152 | 152 | public function getAllPhpFileNamesWithoutExtension() |
153 | 153 | { |
154 | - $files = []; |
|
154 | + $files = [ ]; |
|
155 | 155 | foreach ($this->getAllFileNames() as $file) { |
156 | 156 | if ($this->hasPhpExtension($file)) { |
157 | - $files[] = str_replace('.php', '', $file); |
|
157 | + $files[ ] = str_replace('.php', '', $file); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | return $files; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function hasPhpExtension(string $fileName): bool |
169 | 169 | { |
170 | - return strlen($fileName) > 4 && '.php' === ($fileName[-4] . $fileName[-3] . $fileName[-2] . $fileName[-1]); |
|
170 | + return strlen($fileName) > 4 && '.php' === ($fileName[-4 ].$fileName[-3 ].$fileName[-2 ].$fileName[-1 ]); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $actual = $this->getStatusCode(); |
19 | 19 | PHPUnit::assertTrue( |
20 | 20 | $actual === $status, |
21 | - "Expected status code {$status} but received {$actual}." . "\n" . $this->getContent() |
|
21 | + "Expected status code {$status} but received {$actual}."."\n".$this->getContent() |
|
22 | 22 | ); |
23 | 23 | |
24 | 24 | return $this; |
@@ -26,6 +26,6 @@ discard block |
||
26 | 26 | |
27 | 27 | public function decode() |
28 | 28 | { |
29 | - return json_decode($this->getContent(), true)['data'] ?? json_decode($this->getContent(), true); |
|
29 | + return json_decode($this->getContent(), true)[ 'data' ] ?? json_decode($this->getContent(), true); |
|
30 | 30 | } |
31 | 31 | } |
@@ -19,15 +19,15 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | if ($unwrap) { |
22 | - return json_decode($content, true)['data'] ?? json_decode($content, true); |
|
22 | + return json_decode($content, true)[ 'data' ] ?? json_decode($content, true); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return json_decode($content, true); |
26 | 26 | } |
27 | 27 | |
28 | - protected function http(string $method, string $route, array $payload = [], array $headers = []) : \Foundation\Abstracts\Tests\TestResponse |
|
28 | + protected function http(string $method, string $route, array $payload = [ ], array $headers = [ ]) : \Foundation\Abstracts\Tests\TestResponse |
|
29 | 29 | { |
30 | - if (!in_array($method, ['GET','POST','PATCH','DELETE','PUT'])) { |
|
30 | + if (!in_array($method, [ 'GET', 'POST', 'PATCH', 'DELETE', 'PUT' ])) { |
|
31 | 31 | throw new \Exception("Invalid Http Method"); |
32 | 32 | } |
33 | 33 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | private function loadCommands() |
71 | 71 | { |
72 | 72 | foreach ($this->bootstrapService->getCommands() as $command) { |
73 | - $this->commands($command['class']); |
|
73 | + $this->commands($command[ 'class' ]); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | $moduleModel = null; |
80 | 80 | foreach ($this->bootstrapService->getRoutes() as $route) { |
81 | 81 | Route::group([ |
82 | - 'prefix' => $route['prefix'], |
|
83 | - 'namespace' => $route['controller_namespace'], |
|
84 | - 'domain' => $route['domain'], |
|
85 | - 'middleware' => ['api'], |
|
86 | - ], function () use ($route) { |
|
87 | - require $route['path']; |
|
82 | + 'prefix' => $route[ 'prefix' ], |
|
83 | + 'namespace' => $route[ 'controller_namespace' ], |
|
84 | + 'domain' => $route[ 'domain' ], |
|
85 | + 'middleware' => [ 'api' ], |
|
86 | + ], function() use ($route) { |
|
87 | + require $route[ 'path' ]; |
|
88 | 88 | }); |
89 | - if ($moduleModel !== $route['module_model']) { |
|
90 | - Route::model(strtolower(get_short_class_name($route['module_model'])), $route['module_model']); |
|
89 | + if ($moduleModel !== $route[ 'module_model' ]) { |
|
90 | + Route::model(strtolower(get_short_class_name($route[ 'module_model' ])), $route[ 'module_model' ]); |
|
91 | 91 | } |
92 | - $moduleModel = $route['module_model']; |
|
92 | + $moduleModel = $route[ 'module_model' ]; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | { |
103 | 103 | foreach ($this->bootstrapService->getConfigs() as $config) { |
104 | 104 | $this->mergeConfigFrom( |
105 | - $config['path'], |
|
106 | - $config['name'] |
|
105 | + $config[ 'path' ], |
|
106 | + $config[ 'name' ] |
|
107 | 107 | ); |
108 | 108 | } |
109 | 109 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | foreach ($this->bootstrapService->getFactories() as $factory) { |
119 | 119 | if (!$this->app->environment('production')) { |
120 | - app(Factory::class)->load($factory['path']); |
|
120 | + app(Factory::class)->load($factory[ 'path' ]); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function loadMigrations() |
131 | 131 | { |
132 | 132 | foreach ($this->bootstrapService->getMigrations() as $migration) { |
133 | - $this->loadMigrationsFrom($migration['path']); |
|
133 | + $this->loadMigrationsFrom($migration[ 'path' ]); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | { |
139 | 139 | $app = $this->app; |
140 | 140 | $service = $this->bootstrapService; |
141 | - $this->app->extend('command.seed', function () use ($app, $service) { |
|
142 | - return new SeedCommand($app['db'], $service); |
|
141 | + $this->app->extend('command.seed', function() use ($app, $service) { |
|
142 | + return new SeedCommand($app[ 'db' ], $service); |
|
143 | 143 | }); |
144 | 144 | } |
145 | 145 | |
146 | 146 | private function loadCacheObservers() |
147 | 147 | { |
148 | 148 | foreach ($this->bootstrapService->getModels() as $model) { |
149 | - if ($model['cacheable']) { |
|
150 | - $model['class']::observe(CacheObserver::class); |
|
149 | + if ($model[ 'cacheable' ]) { |
|
150 | + $model[ 'class' ]::observe(CacheObserver::class); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | private function loadModelPolicies() |
156 | 156 | { |
157 | 157 | foreach ($this->bootstrapService->getModels() as $model) { |
158 | - foreach ($model['policies'] as $policy) { |
|
159 | - Gate::policy($model['class'], $policy); |
|
160 | - if ($model['ownable']) { |
|
161 | - Gate::define('access', OwnershipPolicy::class . '@access'); |
|
158 | + foreach ($model[ 'policies' ] as $policy) { |
|
159 | + Gate::policy($model[ 'class' ], $policy); |
|
160 | + if ($model[ 'ownable' ]) { |
|
161 | + Gate::define('access', OwnershipPolicy::class.'@access'); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | private function loadModelObservers() |
168 | 168 | { |
169 | 169 | foreach ($this->bootstrapService->getModels() as $model) { |
170 | - foreach ($model['observers'] as $observer) { |
|
171 | - $model['class']::observe($observer); |
|
170 | + foreach ($model[ 'observers' ] as $observer) { |
|
171 | + $model[ 'class' ]::observe($observer); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | private function loadServiceProviders() |
177 | 177 | { |
178 | 178 | foreach ($this->bootstrapService->getProviders() as $provider) { |
179 | - $this->app->register($provider['class']); |
|
179 | + $this->app->register($provider[ 'class' ]); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | 183 | private function loadListeners() |
184 | 184 | { |
185 | 185 | foreach ($this->bootstrapService->getEvents() as $event) { |
186 | - foreach ($event['listeners'] as $listener) { |
|
187 | - Event::listen($event['class'], $listener); |
|
186 | + foreach ($event[ 'listeners' ] as $listener) { |
|
187 | + Event::listen($event[ 'class' ], $listener); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | protected function getOptions() |
61 | 61 | { |
62 | 62 | return [ |
63 | - ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null], |
|
63 | + [ 'command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null ], |
|
64 | 64 | ]; |
65 | 65 | } |
66 | 66 | |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | */ |
70 | 70 | private function getCommandName() |
71 | 71 | { |
72 | - return $this->option('command') ?? str_replace('command', '', strtolower($this->getModuleName()) . ':' . strtolower($this->getClassName())); |
|
72 | + return $this->option('command') ?? str_replace('command', '', strtolower($this->getModuleName()).':'.strtolower($this->getClassName())); |
|
73 | 73 | } |
74 | 74 | } |
@@ -52,13 +52,13 @@ |
||
52 | 52 | protected function getOptions() |
53 | 53 | { |
54 | 54 | return [ |
55 | - ['sync', null, InputOption::VALUE_NONE, 'Indicates that job should be synchronous.'], |
|
55 | + [ 'sync', null, InputOption::VALUE_NONE, 'Indicates that job should be synchronous.' ], |
|
56 | 56 | ]; |
57 | 57 | } |
58 | 58 | |
59 | 59 | protected function isJobSynchronous(): bool |
60 | 60 | { |
61 | - return once(function () { |
|
61 | + return once(function() { |
|
62 | 62 | $option = $this->option('sync'); |
63 | 63 | return app()->runningInConsole() && !$option ? $this->confirm('Should the job run Synchronously?', false) : $option; |
64 | 64 | }); |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | |
45 | 45 | protected function getModelName(): string |
46 | 46 | { |
47 | - return once(function () { |
|
48 | - return $this->option('model') ?? $this->anticipate('For what model would you like to generate a factory?', [$this->getModuleName()], $this->getModuleName()); |
|
47 | + return once(function() { |
|
48 | + return $this->option('model') ?? $this->anticipate('For what model would you like to generate a factory?', [ $this->getModuleName() ], $this->getModuleName()); |
|
49 | 49 | }); |
50 | 50 | } |
51 | 51 | |
52 | 52 | protected function getClassName() :string |
53 | 53 | { |
54 | - return $this->getModelName() . 'Factory'; |
|
54 | + return $this->getModelName().'Factory'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | protected function stubOptions(): array |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | return [ |
60 | 60 | 'CLASS' => $this->getClassName(), |
61 | 61 | 'MODEL' => $this->getModelName(), |
62 | - 'MODEL_NAMESPACE' => $this->getModuleNamespace() . '\\' . 'Entities' . '\\' . $this->getModelName() |
|
62 | + 'MODEL_NAMESPACE' => $this->getModuleNamespace().'\\'.'Entities'.'\\'.$this->getModelName() |
|
63 | 63 | ]; |
64 | 64 | } |
65 | 65 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | protected function getOptions() |
72 | 72 | { |
73 | 73 | return [ |
74 | - ['model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the factory.', null], |
|
74 | + [ 'model', null, InputOption::VALUE_OPTIONAL, 'The Model name for the factory.', null ], |
|
75 | 75 | ]; |
76 | 76 | } |
77 | 77 | } |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | return [ |
43 | 43 | 'NAMESPACE' => $this->getClassNamespace(), |
44 | 44 | 'CLASS' => $this->getClassName(), |
45 | - 'EVENTNAME' => $this->getModuleNamespace() . '\\' . 'Events' . '\\' . $this->getEventName(), |
|
45 | + 'EVENTNAME' => $this->getModuleNamespace().'\\'.'Events'.'\\'.$this->getEventName(), |
|
46 | 46 | 'SHORTEVENTNAME' => $this->getEventName(), |
47 | 47 | ]; |
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function getEventName(): string |
51 | 51 | { |
52 | - return once(function () { |
|
52 | + return once(function() { |
|
53 | 53 | $eventName = $this->option('event') ?? $this->ask('What is the name of the event that should be listened on?', false) ?? "null"; |
54 | 54 | if ($eventName === null) { |
55 | 55 | throw new Exception("Eventname for listener not given"); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | protected function listenerNeedsQueueing(): bool |
62 | 62 | { |
63 | - return once(function () { |
|
63 | + return once(function() { |
|
64 | 64 | $option = $this->option('queued'); |
65 | 65 | return app()->runningInConsole() && !$option ? $this->confirm('Should the listener be queued?', false) : $option; |
66 | 66 | }); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | protected function afterGeneration(): void |
70 | 70 | { |
71 | - $this->info("don't forget to add the listener to " . $this->getEventName()); |
|
71 | + $this->info("don't forget to add the listener to ".$this->getEventName()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | protected function getOptions() |
91 | 91 | { |
92 | 92 | return [ |
93 | - ['event', 'e', InputOption::VALUE_OPTIONAL, 'The event class being listened for.'], |
|
94 | - ['queued', null, InputOption::VALUE_NONE, 'Indicates the event listener should be queued.'], |
|
93 | + [ 'event', 'e', InputOption::VALUE_OPTIONAL, 'The event class being listened for.' ], |
|
94 | + [ 'queued', null, InputOption::VALUE_NONE, 'Indicates the event listener should be queued.' ], |
|
95 | 95 | ]; |
96 | 96 | } |
97 | 97 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | protected function getDestinationFilePath() |
44 | 44 | { |
45 | - return $this->getModulePath() . $this->filePath . '/' . $this->getFileName(); |
|
45 | + return $this->getModulePath().$this->filePath.'/'.$this->getFileName(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | protected function getFileName() |
52 | 52 | { |
53 | - return $this->getClassName() . '.php'; |
|
53 | + return $this->getClassName().'.php'; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | protected function getModulePath(): string |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | |
61 | 61 | protected function getModuleName(): string |
62 | 62 | { |
63 | - return once(function () { |
|
63 | + return once(function() { |
|
64 | 64 | return Str::studly($this->askModuleName()); |
65 | 65 | }); |
66 | 66 | } |
67 | 67 | |
68 | 68 | private function askModuleName(): string |
69 | 69 | { |
70 | - $moduleName = $this->argument('module') ?? $this->ask('For what module would you like to generate a ' . $this->getGeneratorName() . '.'); |
|
70 | + $moduleName = $this->argument('module') ?? $this->ask('For what module would you like to generate a '.$this->getGeneratorName().'.'); |
|
71 | 71 | |
72 | 72 | if ($moduleName === null) { |
73 | 73 | throw new \Exception("Name of module not set."); |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getClassNamespace($module = null): string |
86 | 86 | { |
87 | - return $this->getModuleNamespace() . str_replace('/', '\\', $this->filePath); |
|
87 | + return $this->getModuleNamespace().str_replace('/', '\\', $this->filePath); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | protected function getModuleNamespace(): string |
92 | 92 | { |
93 | - return 'Modules' . '\\' . $this->getModuleName(); |
|
93 | + return 'Modules'.'\\'.$this->getModuleName(); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | |
118 | 118 | protected function getClassName(): string |
119 | 119 | { |
120 | - return once(function () { |
|
120 | + return once(function() { |
|
121 | 121 | return Str::studly($this->askClassName()); |
122 | 122 | }); |
123 | 123 | } |
124 | 124 | |
125 | 125 | private function askClassName(): string |
126 | 126 | { |
127 | - $className = $this->argument('name') ?? $this->ask('Specify the name of the ' . $this->getGeneratorName() . '.'); |
|
127 | + $className = $this->argument('name') ?? $this->ask('Specify the name of the '.$this->getGeneratorName().'.'); |
|
128 | 128 | ; |
129 | 129 | if ($className === null) { |
130 | - throw new \Exception("Name of " . $this->getGeneratorName() . " not set."); |
|
130 | + throw new \Exception("Name of ".$this->getGeneratorName()." not set."); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | return $className; |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | protected function getArguments() |
142 | 142 | { |
143 | 143 | return [ |
144 | - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
145 | - ['name', InputArgument::OPTIONAL, 'The name of the ' . $this->getGeneratorName() . '.'], |
|
144 | + [ 'module', InputArgument::OPTIONAL, 'The name of module will be used.' ], |
|
145 | + [ 'name', InputArgument::OPTIONAL, 'The name of the '.$this->getGeneratorName().'.' ], |
|
146 | 146 | ]; |
147 | 147 | } |
148 | 148 |