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

+1-9
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

+3-11
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

+3-8
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

+2-10
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

+1-1
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

+1-1
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

+3-2
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

+2-4
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

+1-1
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

+1-1
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

app/Console/Commands/PublishArticles.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\Article;
88
use Illuminate\Console\Command;
99

10-
class PublishArticles extends Command
10+
final class PublishArticles extends Command
1111
{
1212
protected $signature = 'lcm:publish-articles';
1313

app/Console/Commands/SendUnVerifiedMails.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Console\Command;
1010
use Illuminate\Support\Facades\Mail;
1111

12-
class SendUnVerifiedMails extends Command
12+
final class SendUnVerifiedMails extends Command
1313
{
1414
protected $signature = 'lcm:send-unverified-mails';
1515

app/Console/Commands/SendWelcomeMailToUsers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Console\Command;
1010
use Illuminate\Support\Facades\Mail;
1111

12-
class SendWelcomeMailToUsers extends Command
12+
final class SendWelcomeMailToUsers extends Command
1313
{
1414
protected $signature = 'lcm:send-welcome-mails';
1515

app/Console/Commands/UpdateUserBestRepliesPoints.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use App\Models\Thread;
99
use Illuminate\Console\Command;
1010

11-
class UpdateUserBestRepliesPoints extends Command
11+
final class UpdateUserBestRepliesPoints extends Command
1212
{
1313
protected $signature = 'lcm:update-users-bests-replies-points';
1414

app/Console/Commands/UpdateUserDiscussionsPoints.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use App\Models\Discussion;
99
use Illuminate\Console\Command;
1010

11-
class UpdateUserDiscussionsPoints extends Command
11+
final class UpdateUserDiscussionsPoints extends Command
1212
{
1313
protected $signature = 'lcm:update-users-discussions-points';
1414

app/Console/Commands/UpdateUserPostsPoints.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use App\Models\Article;
99
use Illuminate\Console\Command;
1010

11-
class UpdateUserPostsPoints extends Command
11+
final class UpdateUserPostsPoints extends Command
1212
{
1313
protected $signature = 'lcm:update-users-posts-points';
1414

app/Console/Commands/UpdateUserRepliesPoints.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use App\Models\Reply;
99
use Illuminate\Console\Command;
1010

11-
class UpdateUserRepliesPoints extends Command
11+
final class UpdateUserRepliesPoints extends Command
1212
{
1313
protected $signature = 'lcm:update-users-replies-points';
1414

app/Console/Commands/UpdateUserThreadsPoints.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use App\Models\Thread;
99
use Illuminate\Console\Command;
1010

11-
class UpdateUserThreadsPoints extends Command
11+
final class UpdateUserThreadsPoints extends Command
1212
{
1313
protected $signature = 'lcm:update-users-threads-points';
1414

app/Console/Kernel.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44

55
namespace App\Console;
66

7+
use App\Console\Commands\Cleanup\DeleteOldUnverifiedUsers;
78
use Illuminate\Console\Scheduling\Schedule;
89
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
910

10-
class Kernel extends ConsoleKernel
11+
final class Kernel extends ConsoleKernel
1112
{
12-
/**
13-
* The Artisan commands provided by your application.
14-
*
15-
* @var string[]
16-
*/
1713
protected $commands = [
18-
\App\Console\Commands\Cleanup\DeleteOldUnverifiedUsers::class,
14+
DeleteOldUnverifiedUsers::class,
1915
];
2016

2117
protected function schedule(Schedule $schedule): void

app/Contracts/ReactableInterface.php

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
interface ReactableInterface
1111
{
12-
/**
13-
* Returns an Eloquent collection of reactions to the current item.
14-
*/
1512
public function reactions(): MorphToMany;
1613

1714
/**

app/Enums/EnterpriseSize.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44

55
namespace App\Enums;
66

7-
use BenSampo\Enum\Enum;
8-
9-
final class EnterpriseSize extends Enum
7+
enum EnterpriseSize: string
108
{
11-
public const SEED = '1-10';
9+
case SEED = '1-10';
1210

13-
public const SMALL = '11-50';
11+
case SMALL = '11-50';
1412

15-
public const MEDIUM = '51-200';
13+
case MEDIUM = '51-200';
1614

17-
public const LARGE = '201-500';
15+
case LARGE = '201-500';
1816

19-
public const VERY_LARGE = '501-1000';
17+
case VERY_LARGE = '501-1000';
2018

21-
public const ENTERPRISE = '1001-5000';
19+
case ENTERPRISE = '1001-5000';
2220

23-
public const LARGE_ENTERPRISE = '5000+';
21+
case LARGE_ENTERPRISE = '5000+';
2422
}

app/Enums/PaymentType.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
enum PaymentType: string
88
{
99
case SUBSCRIPTION = 'subscription';
10+
1011
case SPONSORING = 'sponsoring';
1112
}

app/Enums/PlanType.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
enum PlanType: string
88
{
99
case DEVELOPER = 'developer';
10+
1011
case ENTERPRISE = 'enterprise';
1112
}

app/Enums/TransactionStatus.php

+3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
enum TransactionStatus: string
88
{
99
case PENDING = 'pending';
10+
1011
case COMPLETE = 'complete';
12+
1113
case CANCELED = 'canceled';
14+
1215
case Failed = 'failed';
1316
}

app/Enums/TransactionType.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
enum TransactionType: string
88
{
99
case ONETIME = 'one-time';
10+
1011
case RECURSIVE = 'recursive';
1112
}

app/Events/ApiRegistered.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\User;
88
use Illuminate\Queue\SerializesModels;
99

10-
class ApiRegistered
10+
final class ApiRegistered
1111
{
1212
use SerializesModels;
1313

app/Events/ArticleWasSubmittedForApproval.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\Article;
88
use Illuminate\Queue\SerializesModels;
99

10-
class ArticleWasSubmittedForApproval
10+
final class ArticleWasSubmittedForApproval
1111
{
1212
use SerializesModels;
1313

app/Events/EmailAddressWasChanged.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Foundation\Events\Dispatchable;
99
use Illuminate\Queue\SerializesModels;
1010

11-
class EmailAddressWasChanged
11+
final class EmailAddressWasChanged
1212
{
1313
use Dispatchable;
1414
use SerializesModels;

app/Events/ReplyWasCreated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\Reply;
88
use Illuminate\Queue\SerializesModels;
99

10-
class ReplyWasCreated
10+
final class ReplyWasCreated
1111
{
1212
use SerializesModels;
1313

app/Events/SponsoringPaymentInitialize.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\Transaction;
88
use Illuminate\Queue\SerializesModels;
99

10-
class SponsoringPaymentInitialize
10+
final class SponsoringPaymentInitialize
1111
{
1212
use SerializesModels;
1313

app/Events/ThreadWasCreated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\Thread;
88
use Illuminate\Queue\SerializesModels;
99

10-
class ThreadWasCreated
10+
final class ThreadWasCreated
1111
{
1212
use SerializesModels;
1313

0 commit comments

Comments
 (0)