@@ -54,25 +54,25 @@ discard block |
||
54 | 54 | { |
55 | 55 | $service = $this->argument('service'); |
56 | 56 | |
57 | - if ( $service ) |
|
57 | + if ($service) |
|
58 | 58 | { |
59 | 59 | $groups = config('service-generator.groups'); |
60 | 60 | |
61 | - $groupKeys = array_keys( $groups ); |
|
61 | + $groupKeys = array_keys($groups); |
|
62 | 62 | |
63 | - $group = $this->choice('For which group do you want to create the service?', $groupKeys ); |
|
63 | + $group = $this->choice('For which group do you want to create the service?', $groupKeys); |
|
64 | 64 | |
65 | 65 | $repository = $this->confirm('Do you want to inject a repository to this service?', false); |
66 | 66 | |
67 | - if ( $repository ) $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
67 | + if ($repository) $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
68 | 68 | else $repository = FALSE; |
69 | 69 | |
70 | 70 | $validator = $this->confirm('Do you want to create and inject a validator for this service?', true); |
71 | 71 | |
72 | - $this->populateValuesForProperties( $service, $group, $repository, $validator ); |
|
72 | + $this->populateValuesForProperties($service, $group, $repository, $validator); |
|
73 | 73 | |
74 | 74 | // Create validator, if it proceeds. |
75 | - if ( $validator ) $this->createValidatorWithInterface(); |
|
75 | + if ($validator) $this->createValidatorWithInterface(); |
|
76 | 76 | |
77 | 77 | // Create service. |
78 | 78 | $this->createServiceWithInterface(); |
@@ -92,20 +92,20 @@ discard block |
||
92 | 92 | * @param $repository |
93 | 93 | * @param $validator |
94 | 94 | */ |
95 | - protected function populateValuesForProperties( $service, $group, $repository, $validator ) |
|
95 | + protected function populateValuesForProperties($service, $group, $repository, $validator) |
|
96 | 96 | { |
97 | 97 | $groups = config('service-generator.groups'); |
98 | 98 | |
99 | 99 | $serviceName = $service.'Service'; |
100 | 100 | |
101 | 101 | $this->serviceGroup = $group; |
102 | - $this->serviceBasePath = $groups[ $group ].'/'.$service; |
|
102 | + $this->serviceBasePath = $groups[$group].'/'.$service; |
|
103 | 103 | $this->serviceNamespace = $group.'\\'.$service; |
104 | 104 | $this->serviceInterfaceName = $serviceName.'Interface'; |
105 | 105 | $this->serviceClassPath = rtrim($this->serviceBasePath, '/').'/src'; |
106 | 106 | $this->serviceClassName = $serviceName; |
107 | 107 | |
108 | - if ( $validator ) |
|
108 | + if ($validator) |
|
109 | 109 | { |
110 | 110 | $this->validatorBasePath = rtrim($this->serviceBasePath, '/').'/Validation'; |
111 | 111 | $this->validatorClassPath = rtrim($this->validatorBasePath, '/').'/src'; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | $this->validatorClassName = $service.'LaravelValidator'; |
115 | 115 | } |
116 | 116 | |
117 | - if ( $repository ) |
|
117 | + if ($repository) |
|
118 | 118 | { |
119 | - $rplc = str_replace( '\\', '/', $repository ); |
|
119 | + $rplc = str_replace('\\', '/', $repository); |
|
120 | 120 | $this->repositoryFullName = $repository; |
121 | - $this->repositoryName = pathinfo( $rplc, PATHINFO_FILENAME ); |
|
121 | + $this->repositoryName = pathinfo($rplc, PATHINFO_FILENAME); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | protected function createValidatorWithInterface() |
129 | 129 | { |
130 | 130 | $validatorInterfaceFullPath = $this->validatorBasePath.'/'.$this->validatorInterfaceName.'.php'; |
131 | - if ( !$this->filesystem->exists( $validatorInterfaceFullPath ) ) |
|
131 | + if (!$this->filesystem->exists($validatorInterfaceFullPath)) |
|
132 | 132 | { |
133 | 133 | // Read the stub and replace |
134 | - $this->makeDirectory( $this->validatorBasePath ); |
|
135 | - $this->filesystem->put( $validatorInterfaceFullPath, $this->compileValidatorInterface() ); |
|
134 | + $this->makeDirectory($this->validatorBasePath); |
|
135 | + $this->filesystem->put($validatorInterfaceFullPath, $this->compileValidatorInterface()); |
|
136 | 136 | $this->info("Validator interface created successfully for '$this->serviceClassName'."); |
137 | 137 | $this->composer->dumpAutoloads(); |
138 | 138 | } else |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | |
143 | 143 | // Now create the class. |
144 | 144 | $validatorClassFullPath = $this->validatorClassPath.'/'.$this->validatorClassName.'.php'; |
145 | - if ( !$this->filesystem->exists( $validatorClassFullPath ) ) |
|
145 | + if (!$this->filesystem->exists($validatorClassFullPath)) |
|
146 | 146 | { |
147 | - $this->makeDirectory( $this->validatorClassPath ); |
|
148 | - $this->filesystem->put( $validatorClassFullPath, $this->compileValidator() ); |
|
147 | + $this->makeDirectory($this->validatorClassPath); |
|
148 | + $this->filesystem->put($validatorClassFullPath, $this->compileValidator()); |
|
149 | 149 | $this->info("Validator created successfully for '$this->serviceClassName'."); |
150 | 150 | $this->composer->dumpAutoloads(); |
151 | 151 | } else |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | protected function createServiceWithInterface() |
161 | 161 | { |
162 | 162 | $serviceInterfaceFullPath = $this->serviceBasePath.'/'.$this->serviceInterfaceName.'.php'; |
163 | - if ( !$this->filesystem->exists( $serviceInterfaceFullPath ) ) |
|
163 | + if (!$this->filesystem->exists($serviceInterfaceFullPath)) |
|
164 | 164 | { |
165 | 165 | // Read the stub and replace |
166 | - $this->makeDirectory( $this->serviceBasePath ); |
|
167 | - $this->filesystem->put( $serviceInterfaceFullPath, $this->compileServiceInterface() ); |
|
166 | + $this->makeDirectory($this->serviceBasePath); |
|
167 | + $this->filesystem->put($serviceInterfaceFullPath, $this->compileServiceInterface()); |
|
168 | 168 | $this->info("Service interface created successfully for '$this->serviceClassName'."); |
169 | 169 | $this->composer->dumpAutoloads(); |
170 | 170 | } else |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | $serviceClassFullPath = $this->serviceClassPath.'/'.$this->serviceClassName.'.php'; |
176 | - if ( !$this->filesystem->exists( $serviceClassFullPath ) ) |
|
176 | + if (!$this->filesystem->exists($serviceClassFullPath)) |
|
177 | 177 | { |
178 | - $this->makeDirectory( $this->serviceClassPath ); |
|
179 | - $this->filesystem->put( $serviceClassFullPath, $this->compileService() ); |
|
178 | + $this->makeDirectory($this->serviceClassPath); |
|
179 | + $this->filesystem->put($serviceClassFullPath, $this->compileService()); |
|
180 | 180 | $this->info("Service '$this->serviceClassName' created successfully."); |
181 | 181 | $this->composer->dumpAutoloads(); |
182 | 182 | } else |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | |
195 | 195 | $classFilePath = $this->serviceBasePath.'/'.$serviceProviderClassName.'.php'; |
196 | 196 | |
197 | - if ( !$this->filesystem->exists( $classFilePath ) ) |
|
197 | + if (!$this->filesystem->exists($classFilePath)) |
|
198 | 198 | { |
199 | - $this->makeDirectory( $this->serviceBasePath ); |
|
200 | - $this->filesystem->put( $classFilePath, $this->compileServiceProvider() ); |
|
199 | + $this->makeDirectory($this->serviceBasePath); |
|
200 | + $this->filesystem->put($classFilePath, $this->compileServiceProvider()); |
|
201 | 201 | $this->info("Service provider created successfully for '$this->serviceClassName'."); |
202 | 202 | $this->composer->dumpAutoloads(); |
203 | 203 | } else |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | protected function compileServiceInterface() |
213 | 213 | { |
214 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-interface.stub'); |
|
214 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-interface.stub'); |
|
215 | 215 | |
216 | 216 | $stub = str_replace('{{serviceInterfaceNamespace}}', $this->serviceNamespace, $stub); |
217 | 217 | $stub = str_replace('{{serviceInterfaceName}}', $this->serviceInterfaceName, $stub); |
@@ -224,38 +224,38 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function compileService() |
226 | 226 | { |
227 | - if ( $this->repositoryName && !$this->validatorClassName ) |
|
227 | + if ($this->repositoryName && !$this->validatorClassName) |
|
228 | 228 | { |
229 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-w-repo.stub'); |
|
230 | - } elseif ( $this->repositoryName && $this->validatorClassName ) |
|
229 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-w-repo.stub'); |
|
230 | + } elseif ($this->repositoryName && $this->validatorClassName) |
|
231 | 231 | { |
232 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-w-repo-validator.stub'); |
|
233 | - } else if ( !$this->repositoryName && $this->validatorClassName ) |
|
232 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-w-repo-validator.stub'); |
|
233 | + } else if (!$this->repositoryName && $this->validatorClassName) |
|
234 | 234 | { |
235 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-w-validator.stub'); |
|
235 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-w-validator.stub'); |
|
236 | 236 | } else |
237 | 237 | { |
238 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service.stub'); |
|
238 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service.stub'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | $stub = str_replace('{{serviceInterfaceNamespace}}', $this->serviceNamespace, $stub); |
242 | 242 | $stub = str_replace('{{serviceInterfaceName}}', $this->serviceInterfaceName, $stub); |
243 | 243 | $stub = str_replace('{{serviceClassName}}', $this->serviceClassName, $stub); |
244 | 244 | |
245 | - if ( $this->repositoryName ) |
|
245 | + if ($this->repositoryName) |
|
246 | 246 | { |
247 | 247 | // Load the values for repository. |
248 | 248 | $stub = str_replace('{{repositoryInterfaceFullName}}', $this->repositoryFullName, $stub); |
249 | 249 | $stub = str_replace('{{repositoryInterfaceName}}', $this->repositoryName, $stub); |
250 | - $stub = str_replace('{{repositoryName}}', lcfirst( str_replace( 'Interface', '', $this->repositoryName ) ), $stub); |
|
250 | + $stub = str_replace('{{repositoryName}}', lcfirst(str_replace('Interface', '', $this->repositoryName)), $stub); |
|
251 | 251 | } |
252 | 252 | |
253 | - if ( $this->validatorClassName ) |
|
253 | + if ($this->validatorClassName) |
|
254 | 254 | { |
255 | 255 | // Load the values for repository. |
256 | 256 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
257 | 257 | $stub = str_replace('{{validatorInterface}}', $this->validatorInterfaceName, $stub); |
258 | - $stub = str_replace('{{validatorName}}', lcfirst( str_replace( 'Interface', '', $this->validatorInterfaceName ) ), $stub); |
|
258 | + $stub = str_replace('{{validatorName}}', lcfirst(str_replace('Interface', '', $this->validatorInterfaceName)), $stub); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $stub; |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | */ |
267 | 267 | protected function compileServiceProvider() |
268 | 268 | { |
269 | - if ( $this->validatorClassName ) |
|
269 | + if ($this->validatorClassName) |
|
270 | 270 | { |
271 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-provider-w-validator.stub'); |
|
271 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-provider-w-validator.stub'); |
|
272 | 272 | } else |
273 | 273 | { |
274 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-provider.stub'); |
|
274 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-provider.stub'); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | $serviceProviderClassName = $this->getServiceProviderName(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $stub = str_replace('{{serviceInterfaceName}}', $this->serviceInterfaceName, $stub); |
282 | 282 | $stub = str_replace('{{serviceClassName}}', $this->serviceClassName, $stub); |
283 | 283 | |
284 | - if ( $this->validatorClassName ) |
|
284 | + if ($this->validatorClassName) |
|
285 | 285 | { |
286 | 286 | // Load the values for repository. |
287 | 287 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | protected function compileValidatorInterface() |
299 | 299 | { |
300 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/validator-interface.stub'); |
|
300 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/validator-interface.stub'); |
|
301 | 301 | |
302 | 302 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
303 | 303 | $stub = str_replace('{{validatorInterface}}', $this->validatorInterfaceName, $stub); |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | protected function compileValidator() |
312 | 312 | { |
313 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/validator.stub'); |
|
313 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/validator.stub'); |
|
314 | 314 | |
315 | 315 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
316 | 316 | $stub = str_replace('{{validatorInterface}}', $this->validatorInterfaceName, $stub); |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | /** |
324 | 324 | * @param $path |
325 | 325 | */ |
326 | - protected function makeDirectory( $path ) |
|
326 | + protected function makeDirectory($path) |
|
327 | 327 | { |
328 | - if ( !$this->filesystem->isDirectory( $path ) ) |
|
328 | + if (!$this->filesystem->isDirectory($path)) |
|
329 | 329 | { |
330 | - $this->filesystem->makeDirectory( $path, 0775, true, true); |
|
330 | + $this->filesystem->makeDirectory($path, 0775, true, true); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 |
@@ -64,15 +64,20 @@ |
||
64 | 64 | |
65 | 65 | $repository = $this->confirm('Do you want to inject a repository to this service?', false); |
66 | 66 | |
67 | - if ( $repository ) $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
68 | - else $repository = FALSE; |
|
67 | + if ( $repository ) { |
|
68 | + $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
69 | + } else { |
|
70 | + $repository = FALSE; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | $validator = $this->confirm('Do you want to create and inject a validator for this service?', true); |
71 | 74 | |
72 | 75 | $this->populateValuesForProperties( $service, $group, $repository, $validator ); |
73 | 76 | |
74 | 77 | // Create validator, if it proceeds. |
75 | - if ( $validator ) $this->createValidatorWithInterface(); |
|
78 | + if ( $validator ) { |
|
79 | + $this->createValidatorWithInterface(); |
|
80 | + } |
|
76 | 81 | |
77 | 82 | // Create service. |
78 | 83 | $this->createServiceWithInterface(); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | // merge default config |
34 | 34 | $this->mergeConfigFrom( |
35 | - __DIR__.$this->configPath , 'repositories' |
|
35 | + __DIR__.$this->configPath, 'repositories' |
|
36 | 36 | ); |
37 | 37 | |
38 | 38 | // And generators. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | private function registerServiceGenerator() |
47 | 47 | { |
48 | - $this->app->singleton('command.service', function ($app) |
|
48 | + $this->app->singleton('command.service', function($app) |
|
49 | 49 | { |
50 | 50 | return $app['OkayBueno\ServiceGenerator\Commands\MakeServiceCommand']; |
51 | 51 | }); |