Skip to content

Commit f4cee3b

Browse files
bhavingajjarStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent 393400d commit f4cee3b

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

src/Commands/GenerateApi.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public function __construct()
3737
*/
3838
public function handle()
3939
{
40-
if (!file_exists(base_path(config('laravel-api-generator.model_directory_path') . '/' . $this->option('model') . '.php'))) {
40+
if (! file_exists(base_path(config('laravel-api-generator.model_directory_path').'/'.$this->option('model').'.php'))) {
4141
$this->error('Model does not exist!');
42+
4243
return false;
4344
}
4445

@@ -72,6 +73,7 @@ public function handle()
7273
}
7374

7475
$this->info('Api Created SuccessFully!');
76+
7577
return true;
7678
}
7779
}

src/LaravelApiGenerator.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class LaravelApiGenerator
88
{
9-
const STUB_DIR = __DIR__ . '/resources/stubs/';
9+
const STUB_DIR = __DIR__.'/resources/stubs/';
1010
protected $model;
1111
protected $result = false;
1212

@@ -23,59 +23,62 @@ public function generate()
2323

2424
public function directoryCreate()
2525
{
26-
if (!file_exists(base_path('app/Http/Controllers/Api'))) {
26+
if (! file_exists(base_path('app/Http/Controllers/Api'))) {
2727
mkdir(base_path('app/Http/Controllers/Api'));
2828
}
29-
if (!file_exists(base_path('app/Http/Resources'))) {
29+
if (! file_exists(base_path('app/Http/Resources'))) {
3030
mkdir(base_path('app/Http/Resources'));
3131
}
3232
}
3333

3434
public function generateController()
3535
{
36-
if (!file_exists(base_path('app/Http/Controllers/Api/' . $this->model . 'Controller.php'))) {
37-
$template = file_get_contents(self::STUB_DIR . 'controller.stub');
36+
if (! file_exists(base_path('app/Http/Controllers/Api/'.$this->model.'Controller.php'))) {
37+
$template = file_get_contents(self::STUB_DIR.'controller.stub');
3838
$template = str_replace('{{modelName}}', $this->model, $template);
3939
$template = str_replace('{{modelNameLower}}', strtolower($this->model), $template);
4040
$template = str_replace('{{modelNameCamel}}', Str::camel($this->model), $template);
41-
file_put_contents(base_path('app/Http/Controllers/Api/' . $this->model . 'Controller.php'), $template);
41+
file_put_contents(base_path('app/Http/Controllers/Api/'.$this->model.'Controller.php'), $template);
4242
$this->result = true;
4343
}
44+
4445
return $this->result;
4546
}
4647

4748
public function generateResource()
4849
{
49-
if (!file_exists(base_path('app/Http/Resources/' . $this->model . 'Resource.php'))) {
50-
$template = file_get_contents(self::STUB_DIR . 'resource.stub');
50+
if (! file_exists(base_path('app/Http/Resources/'.$this->model.'Resource.php'))) {
51+
$template = file_get_contents(self::STUB_DIR.'resource.stub');
5152
$template = str_replace('{{modelName}}', $this->model, $template);
52-
file_put_contents(base_path('app/Http/Resources/' . $this->model . 'Resource.php'), $template);
53+
file_put_contents(base_path('app/Http/Resources/'.$this->model.'Resource.php'), $template);
5354
$this->result = true;
5455
}
56+
5557
return $this->result;
5658
}
5759

5860
public function generateCollection()
5961
{
60-
if (!file_exists(base_path('app/Http/Resources/' . $this->model . 'Collection.php'))) {
61-
$template = file_get_contents(self::STUB_DIR . 'collection.stub');
62+
if (! file_exists(base_path('app/Http/Resources/'.$this->model.'Collection.php'))) {
63+
$template = file_get_contents(self::STUB_DIR.'collection.stub');
6264
$template = str_replace('{{modelName}}', $this->model, $template);
63-
file_put_contents(base_path('app/Http/Resources/' . $this->model . 'Collection.php'), $template);
65+
file_put_contents(base_path('app/Http/Resources/'.$this->model.'Collection.php'), $template);
6466
$this->result = true;
6567
}
68+
6669
return $this->result;
6770
}
6871

69-
7072
public function generateRoute()
7173
{
72-
$template = "Route::apiResource('{{modelNameLower}}', 'Api\{{modelName}}Controller');" . "\n";
74+
$template = "Route::apiResource('{{modelNameLower}}', 'Api\{{modelName}}Controller');"."\n";
7375
$route = str_replace('{{modelNameLower}}', Str::camel(Str::plural($this->model)), $template);
7476
$route = str_replace('{{modelName}}', $this->model, $route);
75-
if (!strpos(file_get_contents(base_path('routes/api.php')), $route)) {
77+
if (! strpos(file_get_contents(base_path('routes/api.php')), $route)) {
7678
file_put_contents(base_path('routes/api.php'), $route, FILE_APPEND);
7779
$this->result = true;
7880
}
81+
7982
return $this->result;
8083
}
8184
}

src/LaravelApiGeneratorServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function boot()
2222

2323
if ($this->app->runningInConsole()) {
2424
$this->publishes([
25-
__DIR__ . '/../config/config.php' => config_path('laravel-api-generator.php'),
25+
__DIR__.'/../config/config.php' => config_path('laravel-api-generator.php'),
2626
], 'config');
2727

2828
// Publishing the views.
@@ -42,7 +42,7 @@ public function boot()
4242

4343
// Registering package commands.
4444
$this->commands([
45-
GenerateApi::class
45+
GenerateApi::class,
4646
]);
4747
}
4848
}
@@ -53,7 +53,7 @@ public function boot()
5353
public function register()
5454
{
5555
// Automatically apply the package configuration
56-
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'laravel-api-generator');
56+
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-api-generator');
5757

5858
// Register the main class to use with the facade
5959
$this->app->singleton('laravel-api-generator', function () {

0 commit comments

Comments
 (0)