@@ -56,25 +56,25 @@ discard block |
||
| 56 | 56 | $service = $this->argument('service'); |
| 57 | 57 | $folder = $this->option('folder'); |
| 58 | 58 | |
| 59 | - if ( $service ) |
|
| 59 | + if ($service) |
|
| 60 | 60 | { |
| 61 | 61 | $groups = config('service-generator.groups'); |
| 62 | 62 | |
| 63 | - $groupKeys = array_keys( $groups ); |
|
| 63 | + $groupKeys = array_keys($groups); |
|
| 64 | 64 | |
| 65 | - $group = $this->choice('For which group do you want to create the service?', $groupKeys ); |
|
| 65 | + $group = $this->choice('For which group do you want to create the service?', $groupKeys); |
|
| 66 | 66 | |
| 67 | 67 | $repository = $this->confirm('Do you want to inject a repository to this service?', false); |
| 68 | 68 | |
| 69 | - if ( $repository ) $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
| 69 | + if ($repository) $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
| 70 | 70 | else $repository = FALSE; |
| 71 | 71 | |
| 72 | 72 | $validator = $this->confirm('Do you want to create and inject a validator for this service?', true); |
| 73 | 73 | |
| 74 | - $this->populateValuesForProperties( $service, $folder, $group, $repository, $validator ); |
|
| 74 | + $this->populateValuesForProperties($service, $folder, $group, $repository, $validator); |
|
| 75 | 75 | |
| 76 | 76 | // Create validator, if it proceeds. |
| 77 | - if ( $validator ) $this->createValidatorWithInterface(); |
|
| 77 | + if ($validator) $this->createValidatorWithInterface(); |
|
| 78 | 78 | |
| 79 | 79 | // Create service. |
| 80 | 80 | $this->createServiceWithInterface(); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @param $repository |
| 95 | 95 | * @param $validator |
| 96 | 96 | */ |
| 97 | - protected function populateValuesForProperties( $service, $folder, $group, $repository, $validator ) |
|
| 97 | + protected function populateValuesForProperties($service, $folder, $group, $repository, $validator) |
|
| 98 | 98 | { |
| 99 | 99 | $groups = config('service-generator.groups'); |
| 100 | 100 | |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | $this->serviceFolder = $folder; |
| 104 | 104 | $this->serviceGroup = $group; |
| 105 | - $this->serviceBasePath = $this->serviceFolder ? $groups[ $group ].'/'.$this->serviceFolder : $groups[ $group ].'/'.$service; |
|
| 105 | + $this->serviceBasePath = $this->serviceFolder ? $groups[$group].'/'.$this->serviceFolder : $groups[$group].'/'.$service; |
|
| 106 | 106 | $this->serviceNamespace = $this->serviceFolder ? $group.'\\'.$this->serviceFolder : $group.'\\'.$service; |
| 107 | 107 | $this->serviceInterfaceName = $serviceName.'Interface'; |
| 108 | 108 | $this->serviceClassPath = rtrim($this->serviceBasePath, '/').'/src'; |
| 109 | 109 | $this->serviceClassName = $serviceName; |
| 110 | 110 | |
| 111 | - if ( $validator ) |
|
| 111 | + if ($validator) |
|
| 112 | 112 | { |
| 113 | 113 | $this->validatorBasePath = rtrim($this->serviceBasePath, '/').'/Validation'; |
| 114 | 114 | $this->validatorClassPath = rtrim($this->validatorBasePath, '/').'/src'; |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | $this->validatorClassName = $service.'LaravelValidator'; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( $repository ) |
|
| 120 | + if ($repository) |
|
| 121 | 121 | { |
| 122 | - $rplc = str_replace( '\\', '/', $repository ); |
|
| 122 | + $rplc = str_replace('\\', '/', $repository); |
|
| 123 | 123 | $this->repositoryFullName = $repository; |
| 124 | - $this->repositoryName = pathinfo( $rplc, PATHINFO_FILENAME ); |
|
| 124 | + $this->repositoryName = pathinfo($rplc, PATHINFO_FILENAME); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | protected function createValidatorWithInterface() |
| 132 | 132 | { |
| 133 | 133 | $validatorInterfaceFullPath = $this->validatorBasePath.'/'.$this->validatorInterfaceName.'.php'; |
| 134 | - if ( !$this->filesystem->exists( $validatorInterfaceFullPath ) ) |
|
| 134 | + if (!$this->filesystem->exists($validatorInterfaceFullPath)) |
|
| 135 | 135 | { |
| 136 | 136 | // Read the stub and replace |
| 137 | - $this->makeDirectory( $this->validatorBasePath ); |
|
| 138 | - $this->filesystem->put( $validatorInterfaceFullPath, $this->compileValidatorInterface() ); |
|
| 137 | + $this->makeDirectory($this->validatorBasePath); |
|
| 138 | + $this->filesystem->put($validatorInterfaceFullPath, $this->compileValidatorInterface()); |
|
| 139 | 139 | $this->info("Validator interface created successfully for '$this->serviceClassName'."); |
| 140 | 140 | $this->composer->dumpAutoloads(); |
| 141 | 141 | } else |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // Now create the class. |
| 147 | 147 | $validatorClassFullPath = $this->validatorClassPath.'/'.$this->validatorClassName.'.php'; |
| 148 | - if ( !$this->filesystem->exists( $validatorClassFullPath ) ) |
|
| 148 | + if (!$this->filesystem->exists($validatorClassFullPath)) |
|
| 149 | 149 | { |
| 150 | - $this->makeDirectory( $this->validatorClassPath ); |
|
| 151 | - $this->filesystem->put( $validatorClassFullPath, $this->compileValidator() ); |
|
| 150 | + $this->makeDirectory($this->validatorClassPath); |
|
| 151 | + $this->filesystem->put($validatorClassFullPath, $this->compileValidator()); |
|
| 152 | 152 | $this->info("Validator created successfully for '$this->serviceClassName'."); |
| 153 | 153 | $this->composer->dumpAutoloads(); |
| 154 | 154 | } else |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | protected function createServiceWithInterface() |
| 164 | 164 | { |
| 165 | 165 | $serviceInterfaceFullPath = $this->serviceBasePath.'/'.$this->serviceInterfaceName.'.php'; |
| 166 | - if ( !$this->filesystem->exists( $serviceInterfaceFullPath ) ) |
|
| 166 | + if (!$this->filesystem->exists($serviceInterfaceFullPath)) |
|
| 167 | 167 | { |
| 168 | 168 | // Read the stub and replace |
| 169 | - $this->makeDirectory( $this->serviceBasePath ); |
|
| 170 | - $this->filesystem->put( $serviceInterfaceFullPath, $this->compileServiceInterface() ); |
|
| 169 | + $this->makeDirectory($this->serviceBasePath); |
|
| 170 | + $this->filesystem->put($serviceInterfaceFullPath, $this->compileServiceInterface()); |
|
| 171 | 171 | $this->info("Service interface created successfully for '$this->serviceClassName'."); |
| 172 | 172 | $this->composer->dumpAutoloads(); |
| 173 | 173 | } else |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $serviceClassFullPath = $this->serviceClassPath.'/'.$this->serviceClassName.'.php'; |
| 179 | - if ( !$this->filesystem->exists( $serviceClassFullPath ) ) |
|
| 179 | + if (!$this->filesystem->exists($serviceClassFullPath)) |
|
| 180 | 180 | { |
| 181 | - $this->makeDirectory( $this->serviceClassPath ); |
|
| 182 | - $this->filesystem->put( $serviceClassFullPath, $this->compileService() ); |
|
| 181 | + $this->makeDirectory($this->serviceClassPath); |
|
| 182 | + $this->filesystem->put($serviceClassFullPath, $this->compileService()); |
|
| 183 | 183 | $this->info("Service '$this->serviceClassName' created successfully."); |
| 184 | 184 | $this->composer->dumpAutoloads(); |
| 185 | 185 | } else |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | $classFilePath = $this->serviceBasePath.'/'.$serviceProviderClassName.'.php'; |
| 199 | 199 | |
| 200 | - if ( !$this->filesystem->exists( $classFilePath ) ) |
|
| 200 | + if (!$this->filesystem->exists($classFilePath)) |
|
| 201 | 201 | { |
| 202 | - $this->makeDirectory( $this->serviceBasePath ); |
|
| 203 | - $this->filesystem->put( $classFilePath, $this->compileServiceProvider() ); |
|
| 202 | + $this->makeDirectory($this->serviceBasePath); |
|
| 203 | + $this->filesystem->put($classFilePath, $this->compileServiceProvider()); |
|
| 204 | 204 | $this->info("Service provider created successfully for '$this->serviceClassName'."); |
| 205 | 205 | $this->composer->dumpAutoloads(); |
| 206 | 206 | } else |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function compileServiceInterface() |
| 216 | 216 | { |
| 217 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-interface.stub'); |
|
| 217 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-interface.stub'); |
|
| 218 | 218 | |
| 219 | 219 | $stub = str_replace('{{serviceInterfaceNamespace}}', $this->serviceNamespace, $stub); |
| 220 | 220 | $stub = str_replace('{{serviceInterfaceName}}', $this->serviceInterfaceName, $stub); |
@@ -227,38 +227,38 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | protected function compileService() |
| 229 | 229 | { |
| 230 | - if ( $this->repositoryName && !$this->validatorClassName ) |
|
| 230 | + if ($this->repositoryName && !$this->validatorClassName) |
|
| 231 | 231 | { |
| 232 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-w-repo.stub'); |
|
| 233 | - } elseif ( $this->repositoryName && $this->validatorClassName ) |
|
| 232 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-w-repo.stub'); |
|
| 233 | + } elseif ($this->repositoryName && $this->validatorClassName) |
|
| 234 | 234 | { |
| 235 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-w-repo-validator.stub'); |
|
| 236 | - } else if ( !$this->repositoryName && $this->validatorClassName ) |
|
| 235 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-w-repo-validator.stub'); |
|
| 236 | + } else if (!$this->repositoryName && $this->validatorClassName) |
|
| 237 | 237 | { |
| 238 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-w-validator.stub'); |
|
| 238 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-w-validator.stub'); |
|
| 239 | 239 | } else |
| 240 | 240 | { |
| 241 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service.stub'); |
|
| 241 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service.stub'); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $stub = str_replace('{{serviceInterfaceNamespace}}', $this->serviceNamespace, $stub); |
| 245 | 245 | $stub = str_replace('{{serviceInterfaceName}}', $this->serviceInterfaceName, $stub); |
| 246 | 246 | $stub = str_replace('{{serviceClassName}}', $this->serviceClassName, $stub); |
| 247 | 247 | |
| 248 | - if ( $this->repositoryName ) |
|
| 248 | + if ($this->repositoryName) |
|
| 249 | 249 | { |
| 250 | 250 | // Load the values for repository. |
| 251 | 251 | $stub = str_replace('{{repositoryInterfaceFullName}}', $this->repositoryFullName, $stub); |
| 252 | 252 | $stub = str_replace('{{repositoryInterfaceName}}', $this->repositoryName, $stub); |
| 253 | - $stub = str_replace('{{repositoryName}}', lcfirst( str_replace( 'Interface', '', $this->repositoryName ) ), $stub); |
|
| 253 | + $stub = str_replace('{{repositoryName}}', lcfirst(str_replace('Interface', '', $this->repositoryName)), $stub); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( $this->validatorClassName ) |
|
| 256 | + if ($this->validatorClassName) |
|
| 257 | 257 | { |
| 258 | 258 | // Load the values for repository. |
| 259 | 259 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
| 260 | 260 | $stub = str_replace('{{validatorInterface}}', $this->validatorInterfaceName, $stub); |
| 261 | - $stub = str_replace('{{validatorName}}', lcfirst( str_replace( 'Interface', '', $this->validatorInterfaceName ) ), $stub); |
|
| 261 | + $stub = str_replace('{{validatorName}}', lcfirst(str_replace('Interface', '', $this->validatorInterfaceName)), $stub); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | return $stub; |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | protected function compileServiceProvider() |
| 271 | 271 | { |
| 272 | - if ( $this->validatorClassName ) |
|
| 272 | + if ($this->validatorClassName) |
|
| 273 | 273 | { |
| 274 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-provider-w-validator.stub'); |
|
| 274 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-provider-w-validator.stub'); |
|
| 275 | 275 | } else |
| 276 | 276 | { |
| 277 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/service-provider.stub'); |
|
| 277 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/service-provider.stub'); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $serviceProviderClassName = $this->getServiceProviderName(); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $stub = str_replace('{{serviceInterfaceName}}', $this->serviceInterfaceName, $stub); |
| 285 | 285 | $stub = str_replace('{{serviceClassName}}', $this->serviceClassName, $stub); |
| 286 | 286 | |
| 287 | - if ( $this->validatorClassName ) |
|
| 287 | + if ($this->validatorClassName) |
|
| 288 | 288 | { |
| 289 | 289 | // Load the values for repository. |
| 290 | 290 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | protected function compileValidatorInterface() |
| 302 | 302 | { |
| 303 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/validator-interface.stub'); |
|
| 303 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/validator-interface.stub'); |
|
| 304 | 304 | |
| 305 | 305 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
| 306 | 306 | $stub = str_replace('{{validatorInterface}}', $this->validatorInterfaceName, $stub); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | protected function compileValidator() |
| 315 | 315 | { |
| 316 | - $stub = $this->filesystem->get(__DIR__ . '/../stubs/validator.stub'); |
|
| 316 | + $stub = $this->filesystem->get(__DIR__.'/../stubs/validator.stub'); |
|
| 317 | 317 | |
| 318 | 318 | $stub = str_replace('{{validatorInterfaceNamespace}}', $this->validatorInterfaceNamespace, $stub); |
| 319 | 319 | $stub = str_replace('{{validatorInterface}}', $this->validatorInterfaceName, $stub); |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | /** |
| 327 | 327 | * @param $path |
| 328 | 328 | */ |
| 329 | - protected function makeDirectory( $path ) |
|
| 329 | + protected function makeDirectory($path) |
|
| 330 | 330 | { |
| 331 | - if ( !$this->filesystem->isDirectory( $path ) ) |
|
| 331 | + if (!$this->filesystem->isDirectory($path)) |
|
| 332 | 332 | { |
| 333 | - $this->filesystem->makeDirectory( $path, 0775, true, true); |
|
| 333 | + $this->filesystem->makeDirectory($path, 0775, true, true); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -66,15 +66,20 @@ |
||
| 66 | 66 | |
| 67 | 67 | $repository = $this->confirm('Do you want to inject a repository to this service?', false); |
| 68 | 68 | |
| 69 | - if ( $repository ) $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
| 70 | - else $repository = FALSE; |
|
| 69 | + if ( $repository ) { |
|
| 70 | + $repository = $this->ask('Please specify the full interface (with namespace) for the repository that you want to inject (ie: MyApp\Repositories\MyRepositoryInterface)'); |
|
| 71 | + } else { |
|
| 72 | + $repository = FALSE; |
|
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | $validator = $this->confirm('Do you want to create and inject a validator for this service?', true); |
| 73 | 76 | |
| 74 | 77 | $this->populateValuesForProperties( $service, $folder, $group, $repository, $validator ); |
| 75 | 78 | |
| 76 | 79 | // Create validator, if it proceeds. |
| 77 | - if ( $validator ) $this->createValidatorWithInterface(); |
|
| 80 | + if ( $validator ) { |
|
| 81 | + $this->createValidatorWithInterface(); |
|
| 82 | + } |
|
| 78 | 83 | |
| 79 | 84 | // Create service. |
| 80 | 85 | $this->createServiceWithInterface(); |