Skip to content

♻️ Apply code refactoring #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@
use Illuminate\Validation\Rule;
use Laravel\Fortify\Contracts\CreatesNewUsers;

class CreateNewUser implements CreatesNewUsers
final class CreateNewUser implements CreatesNewUsers
{
use PasswordValidationRules;

/**
* Validate and create a newly registered user.
*
* @param array $input<string, string>
* @return \App\Models\User
*
* @throws \Illuminate\Validation\ValidationException
*/
public function create(array $input): User
{
Validator::make($input, [
Expand Down
14 changes: 3 additions & 11 deletions app/Actions/Fortify/ResetUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@

namespace App\Actions\Fortify;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\ResetsUserPasswords;

class ResetUserPassword implements ResetsUserPasswords
final class ResetUserPassword implements ResetsUserPasswords
{
use PasswordValidationRules;

/**
* Validate and reset the user's forgotten password.
*
* @param mixed $user
* @param array $input<string string>
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function reset($user, array $input): void
public function reset(User $user, array $input): void
{
Validator::make($input, [
'password' => $this->passwordRules(),
Expand Down
11 changes: 3 additions & 8 deletions app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,17 @@
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\UpdatesUserPasswords;

class UpdateUserPassword implements UpdatesUserPasswords
final class UpdateUserPassword implements UpdatesUserPasswords
{
use PasswordValidationRules;

/**
*
* @param User $user
* @param string[] $input
*/
public function update(User $user, array $input): void
{
Validator::make($input, [
'current_password' => ['required', 'string'],
'password' => $this->passwordRules(),
])->after(function ($validator) use ($user, $input) {
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
])->after(function ($validator) use ($user, $input): void {
if ( ! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
$validator->errors()->add('current_password', __('Le mot de passe fourni ne correspond pas à votre mot de passe actuel.'));
}
})->validateWithBag('updatePassword');
Expand Down
12 changes: 2 additions & 10 deletions app/Actions/Fortify/UpdateUserProfileInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
use Illuminate\Validation\Rule;
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;

class UpdateUserProfileInformation implements UpdatesUserProfileInformation
final class UpdateUserProfileInformation implements UpdatesUserProfileInformation
{
/**
* @param User $user
* @param string[] $input
*/
public function update(User $user, array $input): void
{
Validator::make($input, [
Expand All @@ -39,11 +35,7 @@ public function update(User $user, array $input): void
}
}

/**
* @param mixed $user
* @param string[] $input
*/
protected function updateVerifiedUser(User $user, array $input): void
private function updateVerifiedUser(User $user, array $input): void
{
$user->forceFill([
'name' => $input['name'],
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/AssignUserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\User;
use Illuminate\Console\Command;

class AssignUserRole extends Command
final class AssignUserRole extends Command
{
protected $signature = 'lcm:assign-user-role';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Notifications\SendEMailToDeletedUser;
use Illuminate\Console\Command;

class DeleteOldUnverifiedUsers extends Command
final class DeleteOldUnverifiedUsers extends Command
{
protected $signature = 'lcm:delete-old-unverified-users';

Expand Down
5 changes: 3 additions & 2 deletions app/Console/Commands/CreateAdminUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;
use Exception;

class CreateAdminUser extends Command
final class CreateAdminUser extends Command
{
protected $signature = 'lcm:admin';

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

$user->assignRole('admin');
} catch (\Exception|QueryException $e) {
} catch (Exception|QueryException $e) {
$this->error($e->getMessage());
}
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/GenerateSitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Spatie\Sitemap\SitemapGenerator;
use Spatie\Sitemap\Tags\Url;

class GenerateSitemap extends Command
final class GenerateSitemap extends Command
{
protected $signature = 'sitemap:generate';

Expand All @@ -28,9 +28,7 @@ class GenerateSitemap extends Command
public function handle(): void
{
SitemapGenerator::create(config('app.url'))
->shouldCrawl(function (UriInterface $url) {
return $this->shouldIndex($url->getPath());
})
->shouldCrawl(fn (UriInterface $url) => $this->shouldIndex($url->getPath()))
->hasCrawled(function (Url $url) {
if ($this->shouldNotIndex($url->path())) {
return;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/PostArticleToTelegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Console\Command;
use Illuminate\Notifications\AnonymousNotifiable;

class PostArticleToTelegram extends Command
final class PostArticleToTelegram extends Command
{
protected $signature = 'lcm:post-article-to-telegram';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/PostArticleToTwitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Console\Command;
use Illuminate\Notifications\AnonymousNotifiable;

class PostArticleToTwitter extends Command
final class PostArticleToTwitter extends Command
{
protected $signature = 'lcm:post-article-to-twitter';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/PublishArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\Article;
use Illuminate\Console\Command;

class PublishArticles extends Command
final class PublishArticles extends Command
{
protected $signature = 'lcm:publish-articles';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/SendUnVerifiedMails.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;

class SendUnVerifiedMails extends Command
final class SendUnVerifiedMails extends Command
{
protected $signature = 'lcm:send-unverified-mails';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/SendWelcomeMailToUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;

class SendWelcomeMailToUsers extends Command
final class SendWelcomeMailToUsers extends Command
{
protected $signature = 'lcm:send-welcome-mails';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateUserBestRepliesPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\Thread;
use Illuminate\Console\Command;

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

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateUserDiscussionsPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\Discussion;
use Illuminate\Console\Command;

class UpdateUserDiscussionsPoints extends Command
final class UpdateUserDiscussionsPoints extends Command
{
protected $signature = 'lcm:update-users-discussions-points';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateUserPostsPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\Article;
use Illuminate\Console\Command;

class UpdateUserPostsPoints extends Command
final class UpdateUserPostsPoints extends Command
{
protected $signature = 'lcm:update-users-posts-points';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateUserRepliesPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\Reply;
use Illuminate\Console\Command;

class UpdateUserRepliesPoints extends Command
final class UpdateUserRepliesPoints extends Command
{
protected $signature = 'lcm:update-users-replies-points';

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateUserThreadsPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\Thread;
use Illuminate\Console\Command;

class UpdateUserThreadsPoints extends Command
final class UpdateUserThreadsPoints extends Command
{
protected $signature = 'lcm:update-users-threads-points';

Expand Down
10 changes: 3 additions & 7 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@

namespace App\Console;

use App\Console\Commands\Cleanup\DeleteOldUnverifiedUsers;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
final class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var string[]
*/
protected $commands = [
\App\Console\Commands\Cleanup\DeleteOldUnverifiedUsers::class,
DeleteOldUnverifiedUsers::class,
];

protected function schedule(Schedule $schedule): void
Expand Down
3 changes: 0 additions & 3 deletions app/Contracts/ReactableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

interface ReactableInterface
{
/**
* Returns an Eloquent collection of reactions to the current item.
*/
public function reactions(): MorphToMany;

/**
Expand Down
18 changes: 8 additions & 10 deletions app/Enums/EnterpriseSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

namespace App\Enums;

use BenSampo\Enum\Enum;

final class EnterpriseSize extends Enum
enum EnterpriseSize: string
{
public const SEED = '1-10';
case SEED = '1-10';

public const SMALL = '11-50';
case SMALL = '11-50';

public const MEDIUM = '51-200';
case MEDIUM = '51-200';

public const LARGE = '201-500';
case LARGE = '201-500';

public const VERY_LARGE = '501-1000';
case VERY_LARGE = '501-1000';

public const ENTERPRISE = '1001-5000';
case ENTERPRISE = '1001-5000';

public const LARGE_ENTERPRISE = '5000+';
case LARGE_ENTERPRISE = '5000+';
}
1 change: 1 addition & 0 deletions app/Enums/PaymentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
enum PaymentType: string
{
case SUBSCRIPTION = 'subscription';

case SPONSORING = 'sponsoring';
}
1 change: 1 addition & 0 deletions app/Enums/PlanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
enum PlanType: string
{
case DEVELOPER = 'developer';

case ENTERPRISE = 'enterprise';
}
3 changes: 3 additions & 0 deletions app/Enums/TransactionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
enum TransactionStatus: string
{
case PENDING = 'pending';

case COMPLETE = 'complete';

case CANCELED = 'canceled';

case Failed = 'failed';
}
1 change: 1 addition & 0 deletions app/Enums/TransactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
enum TransactionType: string
{
case ONETIME = 'one-time';

case RECURSIVE = 'recursive';
}
2 changes: 1 addition & 1 deletion app/Events/ApiRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\User;
use Illuminate\Queue\SerializesModels;

class ApiRegistered
final class ApiRegistered
{
use SerializesModels;

Expand Down
2 changes: 1 addition & 1 deletion app/Events/ArticleWasSubmittedForApproval.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\Article;
use Illuminate\Queue\SerializesModels;

class ArticleWasSubmittedForApproval
final class ArticleWasSubmittedForApproval
{
use SerializesModels;

Expand Down
2 changes: 1 addition & 1 deletion app/Events/EmailAddressWasChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class EmailAddressWasChanged
final class EmailAddressWasChanged
{
use Dispatchable;
use SerializesModels;
Expand Down
2 changes: 1 addition & 1 deletion app/Events/ReplyWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\Reply;
use Illuminate\Queue\SerializesModels;

class ReplyWasCreated
final class ReplyWasCreated
{
use SerializesModels;

Expand Down
2 changes: 1 addition & 1 deletion app/Events/SponsoringPaymentInitialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\Transaction;
use Illuminate\Queue\SerializesModels;

class SponsoringPaymentInitialize
final class SponsoringPaymentInitialize
{
use SerializesModels;

Expand Down
2 changes: 1 addition & 1 deletion app/Events/ThreadWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\Thread;
use Illuminate\Queue\SerializesModels;

class ThreadWasCreated
final class ThreadWasCreated
{
use SerializesModels;

Expand Down
Loading