Skip to content

Commit 68d7585

Browse files
committed
style: standardize code formatting and fix CS issues
1 parent ccdc96b commit 68d7585

21 files changed

+332
-338
lines changed

.php-cs-fixer.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@
3939
'keep_multiple_spaces_after_comma' => true,
4040
],
4141
'single_trait_insert_per_statement' => true,
42-
'blank_line_after_namespace' => true,
4342
'blank_line_after_opening_tag' => true,
44-
'braces' => [
45-
'allow_single_line_anonymous_class_with_empty_body' => true,
46-
'allow_single_line_closure' => true,
47-
],
4843
'concat_space' => ['spacing' => 'one'],
4944
'declare_equal_normalize' => true,
5045
'function_typehint_space' => true,
@@ -55,7 +50,6 @@
5550
'new_with_braces' => true,
5651
'no_blank_lines_after_class_opening' => true,
5752
'no_blank_lines_after_phpdoc' => true,
58-
'no_blank_lines_before_namespace' => true,
5953
'no_empty_comment' => true,
6054
'no_empty_phpdoc' => true,
6155
'no_empty_statement' => true,
@@ -106,7 +100,6 @@
106100
'return_type_declaration' => true,
107101
'semicolon_after_instruction' => true,
108102
'short_scalar_cast' => true,
109-
'single_blank_line_before_namespace' => true,
110103
'single_class_element_per_statement' => true,
111104
'single_quote' => true,
112105
'space_after_semicolon' => [

src/Commands/PublishCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ public function handle()
4646
$this->info('1. Run: php artisan migrate');
4747
$this->line('2. Visit /' . config('env-profile-manager.route_prefix', 'env-profile-manager') . ' to manage your environment profiles');
4848
}
49-
}
49+
}

src/EnvProfilesServiceProvider.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class EnvProfilesServiceProvider extends ServiceProvider
1313
public function register(): void
1414
{
1515
$this->mergeConfigFrom(
16-
__DIR__.'/Config/env-profile-manager.php', 'env-profile-manager'
16+
__DIR__ . '/Config/env-profile-manager.php',
17+
'env-profile-manager'
1718
);
1819

1920
$this->app->singleton(EnvFileService::class, function ($app) {
@@ -27,36 +28,36 @@ public function register(): void
2728
public function boot(): void
2829
{
2930
if (config('env-profile-manager.features.web_ui', true)) {
30-
$this->loadRoutesFrom(__DIR__.'/routes/web.php');
31+
$this->loadRoutesFrom(__DIR__ . '/routes/web.php');
3132
}
32-
33+
3334
if (config('env-profile-manager.features.api', true)) {
34-
$this->loadRoutesFrom(__DIR__.'/routes/api.php');
35+
$this->loadRoutesFrom(__DIR__ . '/routes/api.php');
3536
}
36-
37-
$this->loadViewsFrom(__DIR__.'/resources/views', 'env-profile-manager');
38-
$this->loadMigrationsFrom(__DIR__.'/database/migrations');
37+
38+
$this->loadViewsFrom(__DIR__ . '/resources/views', 'env-profile-manager');
39+
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
3940

4041
if ($this->app->runningInConsole()) {
4142
$this->publishes([
42-
__DIR__.'/Config/env-profile-manager.php' => config_path('env-profile-manager.php'),
43+
__DIR__ . '/Config/env-profile-manager.php' => config_path('env-profile-manager.php'),
4344
], 'env-profile-manager-config');
4445

4546
$this->publishes([
46-
__DIR__.'/resources/views' => resource_path('views/vendor/env-profile-manager'),
47+
__DIR__ . '/resources/views' => resource_path('views/vendor/env-profile-manager'),
4748
], 'env-profile-manager-views');
4849

4950
$this->publishes([
50-
__DIR__.'/resources/js' => public_path('vendor/env-profile-manager/js'),
51+
__DIR__ . '/resources/js' => public_path('vendor/env-profile-manager/js'),
5152
], 'env-profile-manager-assets');
5253

5354
$this->publishes([
54-
__DIR__.'/database/migrations' => database_path('migrations'),
55+
__DIR__ . '/database/migrations' => database_path('migrations'),
5556
], 'env-profile-manager-migrations');
5657
}
5758

5859
$this->commands([
5960
Commands\PublishCommand::class,
6061
]);
6162
}
62-
}
63+
}

src/Http/Controllers/EnvProfileController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function index()
2323
$profiles = EnvProfile::orderBy('name')->get();
2424
$currentEnv = $this->envFileService->read();
2525
$appName = config('app.name', 'Laravel');
26-
26+
2727
return view('env-profile-manager::index', compact('profiles', 'currentEnv', 'appName'));
2828
}
2929

@@ -120,4 +120,4 @@ public function updateCurrentEnv(Request $request)
120120
'message' => '.env file updated successfully',
121121
]);
122122
}
123-
}
123+
}

src/Http/Requests/StoreEnvProfileRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ public function messages()
2929
'content.required' => 'Profile content is required.',
3030
];
3131
}
32-
}
32+
}

src/Http/Requests/UpdateEnvProfileRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ public function messages()
3535
'content.required' => 'Profile content is required.',
3636
];
3737
}
38-
}
38+
}

src/Models/EnvProfile.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace LaravelReady\EnvProfiles\Models;
44

5-
use Illuminate\Database\Eloquent\Model;
65
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
77

88
class EnvProfile extends Model
99
{
1010
use HasFactory;
11-
11+
1212
protected $table = 'env_profiles';
13-
13+
1414
protected static function newFactory()
1515
{
1616
return \LaravelReady\EnvProfiles\database\Factories\EnvProfileFactory::new();
@@ -26,7 +26,7 @@ protected static function newFactory()
2626
protected $casts = [
2727
'is_active' => 'boolean',
2828
];
29-
29+
3030
protected $attributes = [
3131
'is_active' => false,
3232
];
@@ -39,7 +39,7 @@ public function scopeActive($query)
3939
public function activate()
4040
{
4141
self::where('is_active', true)->update(['is_active' => false]);
42-
42+
4343
$this->update(['is_active' => true]);
4444
}
4545

@@ -55,7 +55,7 @@ public function getContentAsArray()
5555

5656
foreach ($lines as $line) {
5757
$line = trim($line);
58-
58+
5959
if (empty($line) || strpos($line, '#') === 0) {
6060
continue;
6161
}
@@ -68,4 +68,4 @@ public function getContentAsArray()
6868

6969
return $envArray;
7070
}
71-
}
71+
}

src/Services/EnvFileService.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace LaravelReady\EnvProfiles\Services;
44

5-
use Illuminate\Support\Facades\File;
65
use Illuminate\Support\Facades\Artisan;
6+
use Illuminate\Support\Facades\File;
77

88
class EnvFileService
99
{
@@ -16,7 +16,7 @@ public function __construct()
1616

1717
public function read()
1818
{
19-
if (!File::exists($this->envPath)) {
19+
if (! File::exists($this->envPath)) {
2020
return '';
2121
}
2222

@@ -26,36 +26,36 @@ public function read()
2626
public function write($content)
2727
{
2828
$this->backup();
29-
29+
3030
File::put($this->envPath, $content);
31-
31+
3232
$this->clearConfigCache();
3333
}
3434

3535
public function backup()
3636
{
37-
if (!File::exists($this->envPath) || !config('env-profile-manager.features.backups', true)) {
37+
if (! File::exists($this->envPath) || ! config('env-profile-manager.features.backups', true)) {
3838
return;
3939
}
4040

4141
$backupPath = $this->envPath . '.backup.' . date('YmdHis');
4242
File::copy($this->envPath, $backupPath);
43-
43+
4444
$this->cleanOldBackups();
4545
}
4646

4747
protected function cleanOldBackups()
4848
{
4949
$backupFiles = File::glob(base_path('.env.backup.*'));
5050
$maxBackups = config('env-profile-manager.max_backups', 10);
51-
51+
5252
if (count($backupFiles) > $maxBackups) {
5353
usort($backupFiles, function ($a, $b) {
5454
return filemtime($a) - filemtime($b);
5555
});
56-
56+
5757
$filesToDelete = array_slice($backupFiles, 0, count($backupFiles) - $maxBackups);
58-
58+
5959
foreach ($filesToDelete as $file) {
6060
File::delete($file);
6161
}
@@ -64,7 +64,7 @@ protected function cleanOldBackups()
6464

6565
protected function clearConfigCache()
6666
{
67-
if (app()->runningInConsole() && !app()->runningUnitTests()) {
67+
if (app()->runningInConsole() && ! app()->runningUnitTests()) {
6868
Artisan::call('config:clear');
6969
}
7070
}
@@ -76,7 +76,7 @@ public function parseEnv($content)
7676

7777
foreach ($lines as $line) {
7878
$line = trim($line);
79-
79+
8080
if (empty($line) || strpos($line, '#') === 0) {
8181
continue;
8282
}
@@ -93,15 +93,15 @@ public function parseEnv($content)
9393
protected function parseValue($value)
9494
{
9595
$value = trim($value);
96-
96+
9797
if (preg_match('/^"(.*)"\s*$/', $value, $matches)) {
9898
return $matches[1];
9999
}
100-
100+
101101
if (preg_match('/^\'(.*)\'\s*$/', $value, $matches)) {
102102
return $matches[1];
103103
}
104-
104+
105105
return $value;
106106
}
107-
}
107+
}

src/database/Factories/EnvProfileFactory.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace LaravelReady\EnvProfiles\database\Factories;
44

5-
use LaravelReady\EnvProfiles\Models\EnvProfile;
65
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use LaravelReady\EnvProfiles\Models\EnvProfile;
77

88
class EnvProfileFactory extends Factory
99
{
@@ -44,46 +44,46 @@ public function withoutAppName()
4444
}
4545

4646
/**
47-
* Generate realistic .env content
47+
* Generate realistic .env content.
4848
*/
4949
private function generateEnvContent()
5050
{
5151
$environment = $this->faker->randomElement(['local', 'staging', 'production']);
5252
$debug = $environment === 'production' ? 'false' : 'true';
53-
53+
5454
return implode("\n", [
5555
"APP_NAME=\"{$this->faker->company()}\"",
5656
"APP_ENV={$environment}",
57-
"APP_KEY=base64:" . base64_encode($this->faker->sha256()),
57+
'APP_KEY=base64:' . base64_encode($this->faker->sha256()),
5858
"APP_DEBUG={$debug}",
5959
"APP_URL={$this->faker->url()}",
60-
"",
61-
"LOG_CHANNEL=stack",
62-
"LOG_DEPRECATIONS_CHANNEL=null",
63-
"LOG_LEVEL=debug",
64-
"",
65-
"DB_CONNECTION=mysql",
66-
"DB_HOST=127.0.0.1",
67-
"DB_PORT=3306",
60+
'',
61+
'LOG_CHANNEL=stack',
62+
'LOG_DEPRECATIONS_CHANNEL=null',
63+
'LOG_LEVEL=debug',
64+
'',
65+
'DB_CONNECTION=mysql',
66+
'DB_HOST=127.0.0.1',
67+
'DB_PORT=3306',
6868
"DB_DATABASE={$this->faker->slug()}",
69-
"DB_USERNAME=root",
70-
"DB_PASSWORD=",
71-
"",
72-
"BROADCAST_DRIVER=log",
73-
"CACHE_DRIVER=file",
74-
"FILESYSTEM_DISK=local",
75-
"QUEUE_CONNECTION=sync",
76-
"SESSION_DRIVER=file",
77-
"SESSION_LIFETIME=120",
78-
"",
79-
"MAIL_MAILER=smtp",
80-
"MAIL_HOST=mailhog",
81-
"MAIL_PORT=1025",
82-
"MAIL_USERNAME=null",
83-
"MAIL_PASSWORD=null",
84-
"MAIL_ENCRYPTION=null",
69+
'DB_USERNAME=root',
70+
'DB_PASSWORD=',
71+
'',
72+
'BROADCAST_DRIVER=log',
73+
'CACHE_DRIVER=file',
74+
'FILESYSTEM_DISK=local',
75+
'QUEUE_CONNECTION=sync',
76+
'SESSION_DRIVER=file',
77+
'SESSION_LIFETIME=120',
78+
'',
79+
'MAIL_MAILER=smtp',
80+
'MAIL_HOST=mailhog',
81+
'MAIL_PORT=1025',
82+
'MAIL_USERNAME=null',
83+
'MAIL_PASSWORD=null',
84+
'MAIL_ENCRYPTION=null',
8585
"MAIL_FROM_ADDRESS=\"{$this->faker->email()}\"",
86-
"MAIL_FROM_NAME=\"\${APP_NAME}\"",
86+
'MAIL_FROM_NAME="${APP_NAME}"',
8787
]);
8888
}
89-
}
89+
}

src/database/migrations/2025_01_11_000000_create_env_profiles_table.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
return new class extends Migration
8-
{
7+
return new class () extends Migration {
98
/**
109
* Run the migrations.
1110
*/
@@ -28,4 +27,4 @@ public function down(): void
2827
{
2928
Schema::dropIfExists('env_profiles');
3029
}
31-
};
30+
};

0 commit comments

Comments
 (0)