Skip to content

Commit ac5d29d

Browse files
AlizHarbgithub-actions[bot]
authored andcommitted
Fix PHP code style issues
1 parent 1a36bdc commit ac5d29d

File tree

8 files changed

+33
-25
lines changed

8 files changed

+33
-25
lines changed

src/Commands/InstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function handle(): int
3434
'--provider' => "Spatie\Activitylog\ActivitylogServiceProvider",
3535
'--tag' => 'activitylog-config',
3636
]);
37-
37+
3838
$this->info('Publishing Spatie Activity Log migration...');
3939
$this->call('vendor:publish', [
4040
'--provider' => "Spatie\Activitylog\ActivitylogServiceProvider",

src/Contracts/HasActivityLogTitle.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace AlizHarb\ActivityLog\Contracts;
66

7-
use Illuminate\Database\Eloquent\Model;
8-
97
interface HasActivityLogTitle
108
{
119
public function getActivityLogTitle(): string;

src/Enums/ActivityLogEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Filament\Support\Contracts\HasIcon;
99
use Filament\Support\Contracts\HasLabel;
1010

11-
enum ActivityLogEvent: string implements HasLabel, HasColor, HasIcon
11+
enum ActivityLogEvent: string implements HasColor, HasIcon, HasLabel
1212
{
1313
case Created = 'created';
1414
case Updated = 'updated';

src/Pages/UserActivitiesPage.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Filament\Tables\Contracts\HasTable;
1212
use Filament\Tables\Filters\SelectFilter;
1313
use Filament\Tables\Table;
14-
use Illuminate\Database\Eloquent\Builder;
1514
use Illuminate\Support\Facades\Auth;
1615
use Spatie\Activitylog\Models\Activity;
1716

@@ -143,7 +142,7 @@ public function table(Table $table): Table
143142
->label(__('filament-activity-log::activity.filter.causer'))
144143
->options(function () {
145144
$model = config('auth.providers.users.model');
146-
145+
147146
if (! class_exists($model)) {
148147
return [];
149148
}

src/Resources/ActivityLogs/Tables/ActivityLogTable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function configure(Table $table): Table
217217
);
218218
})
219219
->visible(config('filament-activity-log.table.filters.created_at', true)),
220-
220+
221221
Filter::make('batch_uuid')
222222
->label('Batch UUID')
223223
->hidden()
@@ -244,13 +244,13 @@ public static function configure(Table $table): Table
244244
->visible(config('filament-activity-log.table.actions.timeline', true)),
245245
ViewAction::make()
246246
->visible(config('filament-activity-log.table.actions.view', true)),
247-
247+
248248
Action::make('view_batch')
249249
->label('Batch')
250250
->icon('heroicon-m-rectangle-stack')
251251
->color('gray')
252252
->visible(fn ($record) => $record->batch_uuid)
253-
->url(fn ($record) => request()->url() . '?tableFilters[batch_uuid][value]=' . $record->batch_uuid),
253+
->url(fn ($record) => request()->url().'?tableFilters[batch_uuid][value]='.$record->batch_uuid),
254254

255255
Action::make('revert')
256256
->icon('heroicon-m-arrow-uturn-left')

src/Support/ActivityLogTitle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public static function get(mixed $model): string
3030
if ($title = $model->getAttribute('email')) {
3131
return (string) $title;
3232
}
33-
33+
3434
if ($title = $model->getAttribute('username')) {
3535
return (string) $title;
3636
}
3737

38-
return class_basename($model) . ' #' . $model->getKey();
38+
return class_basename($model).' #'.$model->getKey();
3939
}
4040
}

tests/Feature/ImprovementsTest.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,48 @@
2323
});
2424

2525
it('can set and get cluster in plugin', function () {
26-
$plugin = new ActivityLogPlugin();
26+
$plugin = new ActivityLogPlugin;
2727
$plugin->cluster('System');
2828

2929
expect($plugin->getCluster())->toBe('System');
3030
});
3131

3232
it('resolves subject title using helper', function () {
33-
$user = new class extends Model {
33+
$user = new class extends Model
34+
{
3435
protected $guarded = [];
3536
};
3637
$user->setAttribute('name', 'Test User');
3738
$user->setAttribute('id', 1);
38-
39+
3940
// mimic accessors? No, just attributes.
4041
// getAttribute checks attributes array.
41-
42+
4243
expect(ActivityLogTitle::get($user))->toBe('Test User');
4344

44-
$post = new class extends Model {
45+
$post = new class extends Model
46+
{
4547
protected $guarded = [];
4648
};
4749
$post->setAttribute('title', 'Test Post');
4850
$post->setAttribute('id', 2);
49-
51+
5052
expect(ActivityLogTitle::get($post))->toBe('Test Post');
5153

5254
expect(ActivityLogTitle::get($post))->toBe('Test Post');
5355

54-
$unknown = new class extends Model {
56+
$unknown = new class extends Model
57+
{
5558
// Mocking getKey explicitly as anonymous class table might issue
56-
public function getKey() { return 3; }
57-
public function getTable() { return 'unknowns'; }
59+
public function getKey()
60+
{
61+
return 3;
62+
}
63+
64+
public function getTable()
65+
{
66+
return 'unknowns';
67+
}
5868
};
5969
$unknown->setAttribute('id', 3);
6070

@@ -67,17 +77,17 @@ public function getTable() { return 'unknowns'; }
6777
// but we can verify the action exists on the table if we render it.
6878
// However, recreating table in test is complex.
6979
// We trust standard Filament testing for actions.
70-
80+
7181
// We can test if the Filter query works
7282
$query = Activity::query();
7383
$filter = function ($data, $query) {
74-
$query->when(
84+
$query->when(
7585
$data['value'] ?? null,
7686
fn ($q, $uuid) => $q->where('batch_uuid', $uuid)
7787
);
7888
};
79-
89+
8090
$filter(['value' => 'test-uuid'], $query);
81-
91+
8292
expect($query->toSql())->toContain('batch_uuid');
8393
});

tests/Feature/UserActivitiesPageTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use AlizHarb\ActivityLog\Pages\UserActivitiesPage;
44
use AlizHarb\ActivityLog\Tests\Fixtures\User;
55
use Spatie\Activitylog\Models\Activity;
6+
67
use function Pest\Livewire\livewire;
78

89
beforeEach(function () {
@@ -39,7 +40,7 @@
3940
'causer_id' => 1,
4041
'causer_type' => User::class,
4142
]);
42-
43+
4344
$activity2 = Activity::create([
4445
'log_name' => 'default',
4546
'description' => 'Activity 2',

0 commit comments

Comments
 (0)