Skip to content

Commit 8533626

Browse files
authored
Merge pull request #8 from bhavingajjar/analysis-OMrkLa
Apply fixes from StyleCI
2 parents 0fd541c + dca3389 commit 8533626

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/LaravelApiGenerator.php

Lines changed: 14 additions & 14 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,23 +23,23 @@ 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
{
3636
$this->result = false;
37-
if (!file_exists(base_path('app/Http/Controllers/Api/' . $this->model . 'Controller.php'))) {
37+
if (! file_exists(base_path('app/Http/Controllers/Api/'.$this->model.'Controller.php'))) {
3838
$template = self::getStubContents('controller.stub');
3939
$template = str_replace('{{modelName}}', $this->model, $template);
4040
$template = str_replace('{{modelNameLower}}', strtolower($this->model), $template);
4141
$template = str_replace('{{modelNameCamel}}', Str::camel($this->model), $template);
42-
file_put_contents(base_path('app/Http/Controllers/Api/' . $this->model . 'Controller.php'), $template);
42+
file_put_contents(base_path('app/Http/Controllers/Api/'.$this->model.'Controller.php'), $template);
4343
$this->result = true;
4444
}
4545

@@ -49,17 +49,17 @@ public function generateController()
4949
public function generateResource()
5050
{
5151
$this->result = false;
52-
if (!file_exists(base_path('app/Http/Resources/' . $this->model . 'Resource.php'))) {
53-
$model = app("App\\" . $this->model);
52+
if (! file_exists(base_path('app/Http/Resources/'.$this->model.'Resource.php'))) {
53+
$model = app('App\\'.$this->model);
5454
$columns = $model->getConnection()->getSchemaBuilder()->getColumnListing($model->getTable());
5555
$print_columns = null;
5656
foreach ($columns as $key => $column) {
57-
$print_columns .= "'" . $column . "'" . ' => $this->' . $column . ', ' . "\n \t\t\t";
57+
$print_columns .= "'".$column."'".' => $this->'.$column.', '."\n \t\t\t";
5858
}
5959
$template = self::getStubContents('resource.stub');
6060
$template = str_replace('{{modelName}}', $this->model, $template);
6161
$template = str_replace('{{columns}}', $print_columns, $template);
62-
file_put_contents(base_path('app/Http/Resources/' . $this->model . 'Resource.php'), $template);
62+
file_put_contents(base_path('app/Http/Resources/'.$this->model.'Resource.php'), $template);
6363
$this->result = true;
6464
}
6565

@@ -69,10 +69,10 @@ public function generateResource()
6969
public function generateCollection()
7070
{
7171
$this->result = false;
72-
if (!file_exists(base_path('app/Http/Resources/' . $this->model . 'Collection.php'))) {
72+
if (! file_exists(base_path('app/Http/Resources/'.$this->model.'Collection.php'))) {
7373
$template = self::getStubContents('collection.stub');
7474
$template = str_replace('{{modelName}}', $this->model, $template);
75-
file_put_contents(base_path('app/Http/Resources/' . $this->model . 'Collection.php'), $template);
75+
file_put_contents(base_path('app/Http/Resources/'.$this->model.'Collection.php'), $template);
7676
$this->result = true;
7777
}
7878

@@ -82,10 +82,10 @@ public function generateCollection()
8282
public function generateRoute()
8383
{
8484
$this->result = false;
85-
$template = "Route::apiResource('{{modelNameLower}}', 'Api\{{modelName}}Controller');" . "\n";
85+
$template = "Route::apiResource('{{modelNameLower}}', 'Api\{{modelName}}Controller');"."\n";
8686
$route = str_replace('{{modelNameLower}}', Str::camel(Str::plural($this->model)), $template);
8787
$route = str_replace('{{modelName}}', $this->model, $route);
88-
if (!strpos(file_get_contents(base_path('routes/api.php')), $route)) {
88+
if (! strpos(file_get_contents(base_path('routes/api.php')), $route)) {
8989
file_put_contents(base_path('routes/api.php'), $route, FILE_APPEND);
9090
$this->result = true;
9191
}
@@ -95,6 +95,6 @@ public function generateRoute()
9595

9696
private function getStubContents($stubName)
9797
{
98-
return file_get_contents(self::STUB_DIR . $stubName);
98+
return file_get_contents(self::STUB_DIR.$stubName);
9999
}
100100
}

0 commit comments

Comments
 (0)