Skip to content

Commit c7db853

Browse files
committed
fix: (LAR-87) Execute composer lint
1 parent 0658efc commit c7db853

File tree

6 files changed

+49
-42
lines changed

6 files changed

+49
-42
lines changed

app/Actions/SpamReport/SpamReportContent.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Actions\SpamReport;
46

5-
use App\Models\User;
6-
use Livewire\Component;
77
use App\Models\SpamReport;
8+
use App\Models\User;
9+
use App\Notifications\ContentReportedSpamNotification;
810
use Illuminate\Support\Facades\Auth;
911
use Illuminate\Support\Facades\Notification;
10-
use App\Notifications\ContentReportedNotification;
11-
use App\Notifications\ContentReportedSpamNotification;
12+
use Livewire\Component;
1213

13-
class SpamReportContent extends Component
14+
final class SpamReportContent extends Component
1415
{
1516
public $contentId;
17+
1618
public $contentType;
19+
1720
public $reason;
21+
1822
public $alreadyReported;
1923

20-
public function mount($contentId, $contentType)
24+
public function mount($contentId, $contentType): void
2125
{
2226
$this->contentId = $contentId;
2327
$this->contentType = $contentType;
2428
$this->alreadyReported = SpamReport::where('user_id', Auth::id())
25-
->where('reportable_id', $contentId)
26-
->where('reportable_type', $contentType)
27-
->exists();
29+
->where('reportable_id', $contentId)
30+
->where('reportable_type', $contentType)
31+
->exists();
2832
}
2933

30-
public function report()
34+
public function report(): void
3135
{
32-
if (!Auth::check()) {
36+
if (! Auth::check()) {
3337
abort(403, 'Vous devez être connecté pour signaler du contenu.');
3438
}
3539

36-
if (!Auth::user()->hasVerifiedEmail()) {
40+
if (! Auth::user()->hasVerifiedEmail()) {
3741
$this->addError('email', 'Vous devez avoir un email vérifié pour signaler du contenu.');
42+
3843
return;
3944
}
4045

4146
if ($this->alreadyReported) {
4247
$this->addError('alreadyReported', 'Vous avez déjà signalé ce contenu.');
48+
4349
return;
4450
}
4551

app/Models/SpamReport.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ final class SpamReport extends Model
1212
use HasFactory;
1313

1414
protected $fillable = [
15-
'user_id',
15+
'user_id',
1616
'reportable_id',
17-
'reportable_type',
18-
'reason',
19-
'status'
17+
'reportable_type',
18+
'reason',
19+
'status',
2020
];
2121

2222
public function user()
2323
{
2424
return $this->belongsTo(User::class);
2525
}
26-
26+
2727
public function reportable()
2828
{
2929
return $this->morphTo();

app/Notifications/ContentReportedSpamNotification.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace App\Notifications;
66

77
use Illuminate\Bus\Queueable;
8-
use Illuminate\Contracts\Queue\ShouldQueue;
98
use Illuminate\Notifications\Messages\MailMessage;
109
use Illuminate\Notifications\Notification;
1110

@@ -14,6 +13,7 @@ final class ContentReportedSpamNotification extends Notification
1413
use Queueable;
1514

1615
public $contentId;
16+
1717
public $contentType;
1818

1919
public function __construct($contentId, $contentType)
@@ -30,16 +30,16 @@ public function via(object $notifiable): array
3030
public function toMail(): MailMessage
3131
{
3232
return (new MailMessage)
33-
->subject('Nouveau contenu signalé')
34-
->line("Un contenu a été signalé sur la plateforme. Voici les détails :")
35-
->line("Type de contenu : " . class_basename($this->contentType))
36-
->line("ID du contenu : " . $this->contentId)
37-
->action('Voir le contenu signalé', route('admin.reported-content.show', [
38-
'contentType' => $this->contentType,
39-
'contentId' => $this->contentId
40-
]))
41-
->line("Veuillez vérifier ce contenu pour décider des actions à entreprendre.")
42-
->line('Merci pour votre attention.');
33+
->subject('Nouveau contenu signalé')
34+
->line('Un contenu a été signalé sur la plateforme. Voici les détails :')
35+
->line('Type de contenu : '.class_basename($this->contentType))
36+
->line('ID du contenu : '.$this->contentId)
37+
->action('Voir le contenu signalé', route('admin.reported-content.show', [
38+
'contentType' => $this->contentType,
39+
'contentId' => $this->contentId,
40+
]))
41+
->line('Veuillez vérifier ce contenu pour décider des actions à entreprendre.')
42+
->line('Merci pour votre attention.');
4343
}
4444

4545
public function toArray(object $notifiable): array

database/factories/RoleFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Database\Factories;
46

57
use Illuminate\Database\Eloquent\Factories\Factory;
68
use Spatie\Permission\Models\Role;
79

8-
class RoleFactory extends Factory
10+
final class RoleFactory extends Factory
911
{
1012
protected $model = Role::class;
1113

database/migrations/2024_11_13_155231_create_spam_reports_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
88

9-
return new class () extends Migration
9+
return new class extends Migration
1010
{
1111
public function up(): void
1212
{

tests/Feature/Actions/SpamReports/SpamReportsTest.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@
22

33
declare(strict_types=1);
44

5-
use App\Models\User;
65
use App\Models\Article;
76
use App\Models\SpamReport;
7+
use App\Models\User;
8+
use App\Notifications\ContentReportedSpamNotification;
89
use Illuminate\Foundation\Testing\RefreshDatabase;
910
use Illuminate\Support\Facades\Notification;
10-
use App\Notifications\ContentReportedSpamNotification;
1111
use Livewire\Livewire;
12-
use Spatie\Permission\Models\Role;
1312

1413
uses(RefreshDatabase::class);
1514

16-
beforeEach(function () {
15+
beforeEach(function (): void {
1716
\Database\Factories\RoleFactory::new()->admin()->create();
1817
\Database\Factories\RoleFactory::new()->moderator()->create();
1918

2019
Notification::fake();
2120
});
2221

23-
it('does not allow a guest to report content', function () {
22+
it('does not allow a guest to report content', function (): void {
2423
$article = Article::factory()->create();
2524

2625
Livewire::test('spam-report-content', ['contentId' => $article->id, 'contentType' => Article::class])
2726
->call('spamReport')
2827
->assertForbidden();
2928
});
3029

31-
it('does not allow a user with unverified email to report content', function () {
30+
it('does not allow a user with unverified email to report content', function (): void {
3231
$user = User::factory()->unverified()->create();
3332
$this->actingAs($user);
3433

@@ -40,7 +39,7 @@
4039
->assertSee('Vous devez avoir un email vérifié pour signaler du contenu');
4140
});
4241

43-
it('allows a verified user to report content', function () {
42+
it('allows a verified user to report content', function (): void {
4443
$user = User::factory()->create();
4544
$this->actingAs($user);
4645

@@ -58,7 +57,7 @@
5857
]);
5958
});
6059

61-
it('does not allow a user to report the same content multiple times', function () {
60+
it('does not allow a user to report the same content multiple times', function (): void {
6261
$user = User::factory()->create();
6362
$this->actingAs($user);
6463

@@ -72,7 +71,7 @@
7271
->assertSee('Vous avez déjà signalé ce contenu.');
7372
});
7473

75-
it('shows a reported badge only to the user who reported the content', function () {
74+
it('shows a reported badge only to the user who reported the content', function (): void {
7675
$reporter = User::factory()->create();
7776
$otherUser = User::factory()->create();
7877

@@ -91,7 +90,7 @@
9190
->assertDontSee('Badge Signalé');
9291
});
9392

94-
it('sends a notification to admins and moderators when content is reported', function () {
93+
it('sends a notification to admins and moderators when content is reported', function (): void {
9594
$user = User::factory()->create();
9695
$admin = User::factory()->create();
9796
$moderator = User::factory()->create();
@@ -109,7 +108,7 @@
109108
Notification::assertSentTo([$admin, $moderator], ContentReportedSpamNotification::class);
110109
});
111110

112-
it('allows an admin to see reported content menu', function () {
111+
it('allows an admin to see reported content menu', function (): void {
113112
$admin = User::factory()->create();
114113

115114
$admin->assignRole('admin');
@@ -121,7 +120,7 @@
121120
->assertSee('Contenus Signalés');
122121
});
123122

124-
it('allows an admin to unmark content as reported', function () {
123+
it('allows an admin to unmark content as reported', function (): void {
125124
$admin = User::factory()->create();
126125

127126
$admin->assignRole('admin');

0 commit comments

Comments
 (0)