Skip to content

Commit b7fe4c0

Browse files
authored
♻️ Apply code refactoring (#130)
* ♻️ Apply code refactoring * ✏️ Fix Enterprise migration
1 parent fc5c423 commit b7fe4c0

File tree

267 files changed

+650
-1419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+650
-1419
lines changed

app/Actions/Fortify/CreateNewUser.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@
1111
use Illuminate\Validation\Rule;
1212
use Laravel\Fortify\Contracts\CreatesNewUsers;
1313

14-
class CreateNewUser implements CreatesNewUsers
14+
final class CreateNewUser implements CreatesNewUsers
1515
{
1616
use PasswordValidationRules;
1717

18-
/**
19-
* Validate and create a newly registered user.
20-
*
21-
* @param array $input<string, string>
22-
* @return \App\Models\User
23-
*
24-
* @throws \Illuminate\Validation\ValidationException
25-
*/
2618
public function create(array $input): User
2719
{
2820
Validator::make($input, [

app/Actions/Fortify/ResetUserPassword.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@
44

55
namespace App\Actions\Fortify;
66

7+
use App\Models\User;
78
use Illuminate\Support\Facades\Hash;
89
use Illuminate\Support\Facades\Validator;
910
use Laravel\Fortify\Contracts\ResetsUserPasswords;
1011

11-
class ResetUserPassword implements ResetsUserPasswords
12+
final class ResetUserPassword implements ResetsUserPasswords
1213
{
1314
use PasswordValidationRules;
1415

15-
/**
16-
* Validate and reset the user's forgotten password.
17-
*
18-
* @param mixed $user
19-
* @param array $input<string string>
20-
* @return void
21-
*
22-
* @throws \Illuminate\Validation\ValidationException
23-
*/
24-
public function reset($user, array $input): void
16+
public function reset(User $user, array $input): void
2517
{
2618
Validator::make($input, [
2719
'password' => $this->passwordRules(),

app/Actions/Fortify/UpdateUserPassword.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,17 @@
99
use Illuminate\Support\Facades\Validator;
1010
use Laravel\Fortify\Contracts\UpdatesUserPasswords;
1111

12-
class UpdateUserPassword implements UpdatesUserPasswords
12+
final class UpdateUserPassword implements UpdatesUserPasswords
1313
{
1414
use PasswordValidationRules;
1515

16-
/**
17-
*
18-
* @param User $user
19-
* @param string[] $input
20-
*/
2116
public function update(User $user, array $input): void
2217
{
2318
Validator::make($input, [
2419
'current_password' => ['required', 'string'],
2520
'password' => $this->passwordRules(),
26-
])->after(function ($validator) use ($user, $input) {
27-
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
21+
])->after(function ($validator) use ($user, $input): void {
22+
if ( ! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
2823
$validator->errors()->add('current_password', __('Le mot de passe fourni ne correspond pas à votre mot de passe actuel.'));
2924
}
3025
})->validateWithBag('updatePassword');

app/Actions/Fortify/UpdateUserProfileInformation.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
use Illuminate\Validation\Rule;
1010
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
1111

12-
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
12+
final class UpdateUserProfileInformation implements UpdatesUserProfileInformation
1313
{
14-
/**
15-
* @param User $user
16-
* @param string[] $input
17-
*/
1814
public function update(User $user, array $input): void
1915
{
2016
Validator::make($input, [
@@ -39,11 +35,7 @@ public function update(User $user, array $input): void
3935
}
4036
}
4137

42-
/**
43-
* @param mixed $user
44-
* @param string[] $input
45-
*/
46-
protected function updateVerifiedUser(User $user, array $input): void
38+
private function updateVerifiedUser(User $user, array $input): void
4739
{
4840
$user->forceFill([
4941
'name' => $input['name'],

app/Console/Commands/AssignUserRole.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\User;
88
use Illuminate\Console\Command;
99

10-
class AssignUserRole extends Command
10+
final class AssignUserRole extends Command
1111
{
1212
protected $signature = 'lcm:assign-user-role';
1313

app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use App\Notifications\SendEMailToDeletedUser;
99
use Illuminate\Console\Command;
1010

11-
class DeleteOldUnverifiedUsers extends Command
11+
final class DeleteOldUnverifiedUsers extends Command
1212
{
1313
protected $signature = 'lcm:delete-old-unverified-users';
1414

app/Console/Commands/CreateAdminUser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
use Illuminate\Console\Command;
99
use Illuminate\Database\QueryException;
1010
use Illuminate\Support\Facades\Hash;
11+
use Exception;
1112

12-
class CreateAdminUser extends Command
13+
final class CreateAdminUser extends Command
1314
{
1415
protected $signature = 'lcm:admin';
1516

@@ -50,7 +51,7 @@ protected function createUser(): void
5051
$user = User::query()->create($userData);
5152

5253
$user->assignRole('admin');
53-
} catch (\Exception|QueryException $e) {
54+
} catch (Exception|QueryException $e) {
5455
$this->error($e->getMessage());
5556
}
5657
}

app/Console/Commands/GenerateSitemap.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Spatie\Sitemap\SitemapGenerator;
1111
use Spatie\Sitemap\Tags\Url;
1212

13-
class GenerateSitemap extends Command
13+
final class GenerateSitemap extends Command
1414
{
1515
protected $signature = 'sitemap:generate';
1616

@@ -28,9 +28,7 @@ class GenerateSitemap extends Command
2828
public function handle(): void
2929
{
3030
SitemapGenerator::create(config('app.url'))
31-
->shouldCrawl(function (UriInterface $url) {
32-
return $this->shouldIndex($url->getPath());
33-
})
31+
->shouldCrawl(fn (UriInterface $url) => $this->shouldIndex($url->getPath()))
3432
->hasCrawled(function (Url $url) {
3533
if ($this->shouldNotIndex($url->path())) {
3634
return;

app/Console/Commands/PostArticleToTelegram.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Console\Command;
1010
use Illuminate\Notifications\AnonymousNotifiable;
1111

12-
class PostArticleToTelegram extends Command
12+
final class PostArticleToTelegram extends Command
1313
{
1414
protected $signature = 'lcm:post-article-to-telegram';
1515

app/Console/Commands/PostArticleToTwitter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Console\Command;
1010
use Illuminate\Notifications\AnonymousNotifiable;
1111

12-
class PostArticleToTwitter extends Command
12+
final class PostArticleToTwitter extends Command
1313
{
1414
protected $signature = 'lcm:post-article-to-twitter';
1515

0 commit comments

Comments
 (0)