Skip to content

Commit ac3314f

Browse files
committed
Code style fix
1 parent f3e8c61 commit ac3314f

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

src/Console/MakeModuleCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private function createServiceProvider(): void
6161
$path = base_path("modules/{$this->moduleName}/{$this->moduleName}ServiceProvider.php");
6262

6363
file_put_contents($path, $stub);
64-
64+
6565
$this->call('modular:register-provider', ['name' => $this->moduleName]);
6666
}
6767

@@ -90,6 +90,4 @@ private function createModuleDirectoryStructure(): bool
9090

9191
return true;
9292
}
93-
94-
95-
}
93+
}

src/Console/RegisterServiceProviderCommand.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,30 @@ public function handle(): int
1616

1717
if ($this->registerServiceProvider($moduleName)) {
1818
$this->info("Service provider for module {$moduleName} registered successfully.");
19+
1920
return self::SUCCESS;
2021
}
2122

2223
$this->error("Service provider for module {$moduleName} is already registered.");
24+
2325
return self::FAILURE;
2426
}
2527

2628
public function registerServiceProvider(string $moduleName): bool
2729
{
2830
$providerPath = base_path('bootstrap/providers.php');
2931
$content = file_get_contents($providerPath);
30-
32+
3133
$providerClass = "Modules\\{$moduleName}\\{$moduleName}ServiceProvider::class";
32-
34+
3335
// Check if provider already exists
3436
if (strpos($content, $providerClass) !== false) {
3537
return false;
3638
}
37-
39+
3840
// Split content into lines
3941
$lines = explode("\n", $content);
40-
42+
4143
// Find the position of the closing bracket
4244
$returnArrayIndex = -1;
4345
foreach ($lines as $index => $line) {
@@ -46,17 +48,17 @@ public function registerServiceProvider(string $moduleName): bool
4648
break;
4749
}
4850
}
49-
51+
5052
if ($returnArrayIndex === -1) {
5153
return false;
5254
}
53-
55+
5456
// Insert the new provider before the closing bracket
5557
array_splice($lines, $returnArrayIndex, 0, " {$providerClass},");
56-
58+
5759
// Join the lines back together
5860
$updatedContent = implode("\n", $lines);
59-
61+
6062
return (bool) file_put_contents($providerPath, $updatedContent);
6163
}
62-
}
64+
}

src/ModularServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ public function configurePackage(Package $package): void
5454
->hasCommand(RegisterServiceProviderCommand::class);
5555

5656
}
57-
}
57+
}

tests/Console/RegisterServiceProviderCommandTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
// Create a temporary providers.php file for testing
1818
$filesystem = new Filesystem;
1919
$bootstrapPath = $this->app->bootstrapPath();
20-
20+
2121
// Ensure bootstrap directory exists
22-
if (!$filesystem->exists($bootstrapPath)) {
22+
if (! $filesystem->exists($bootstrapPath)) {
2323
$filesystem->makeDirectory($bootstrapPath, 0755, true);
2424
}
2525

2626
// Create providers.php with initial content
27-
$filesystem->put($bootstrapPath . '/providers.php', $initialProvidersContent);
27+
$filesystem->put($bootstrapPath.'/providers.php', $initialProvidersContent);
2828
});
2929

3030
afterEach(function () use ($initialProvidersContent) {
3131
// Restore the providers.php file to its initial state
3232
$filesystem = new Filesystem;
3333
$bootstrapPath = $this->app->bootstrapPath();
34-
$filesystem->put($bootstrapPath . '/providers.php', $initialProvidersContent);
34+
$filesystem->put($bootstrapPath.'/providers.php', $initialProvidersContent);
3535
});
3636

3737
/**
@@ -50,8 +50,8 @@ function getPackageProviders($app)
5050
->assertSuccessful()
5151
->expectsOutput('Service provider for module Blog registered successfully.');
5252

53-
$content = file_get_contents($this->app->bootstrapPath() . '/providers.php');
54-
53+
$content = file_get_contents($this->app->bootstrapPath().'/providers.php');
54+
5555
// Check that the new provider was added
5656
expect($content)
5757
->toContain('Modules\Blog\BlogServiceProvider::class');
@@ -68,16 +68,16 @@ function getPackageProviders($app)
6868
->expectsOutput('Service provider for module Blog is already registered.');
6969

7070
// Verify the provider appears only once
71-
$content = file_get_contents($this->app->bootstrapPath() . '/providers.php');
71+
$content = file_get_contents($this->app->bootstrapPath().'/providers.php');
7272
expect(substr_count($content, 'Modules\Blog\BlogServiceProvider::class'))->toBe(1);
7373
});
7474

7575
test('it maintains existing providers and formatting when adding new provider', function () {
7676
$this->artisan('modular:register-provider', ['name' => 'Blog'])
7777
->assertSuccessful();
7878

79-
$content = file_get_contents($this->app->bootstrapPath() . '/providers.php');
80-
79+
$content = file_get_contents($this->app->bootstrapPath().'/providers.php');
80+
8181
// Verify the structure is maintained
8282
expect($content)
8383
->toContain('<?php')
@@ -95,9 +95,9 @@ function getPackageProviders($app)
9595
->assertSuccessful();
9696
$this->artisan('modular:register-provider', ['name' => 'Shop'])
9797
->assertSuccessful();
98-
99-
$content = file_get_contents($this->app->bootstrapPath() . '/providers.php');
100-
98+
99+
$content = file_get_contents($this->app->bootstrapPath().'/providers.php');
100+
101101
// Verify both new providers were added while maintaining existing ones
102102
expect($content)
103103
->toContain('Modules\Blog\BlogServiceProvider::class')
@@ -112,7 +112,7 @@ function getPackageProviders($app)
112112

113113
test('registerServiceProvider method returns correct boolean', function () {
114114
$command = $this->app->make(RegisterServiceProviderCommand::class);
115-
115+
116116
expect($command->registerServiceProvider('NewModule'))->toBeTrue()
117117
->and($command->registerServiceProvider('NewModule'))->toBeFalse();
118-
});
118+
});

0 commit comments

Comments
 (0)