Skip to content

Commit eaf5513

Browse files
committed
Linting updates
1 parent 0db7b5c commit eaf5513

File tree

4 files changed

+48
-58
lines changed

4 files changed

+48
-58
lines changed

src/Filament/Concerns/HasSidebar.php

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Kirschbaum\Commentions\Filament\Concerns;
44

5+
use Closure;
56
use Illuminate\Database\Eloquent\Model;
67
use Kirschbaum\Commentions\Config;
78
use Kirschbaum\Commentions\Contracts\Commenter;
8-
use Closure;
99

1010
trait HasSidebar
1111
{
@@ -60,6 +60,48 @@ public function showSubscribers(): bool
6060
return $this->showSubscribers;
6161
}
6262

63+
public function subscribeLabel(Closure|string $label): static
64+
{
65+
$this->subscribeLabelOverride = $label;
66+
67+
return $this;
68+
}
69+
70+
public function unsubscribeLabel(Closure|string $label): static
71+
{
72+
$this->unsubscribeLabelOverride = $label;
73+
74+
return $this;
75+
}
76+
77+
public function subscribeIcon(Closure|string $icon): static
78+
{
79+
$this->subscribeIconOverride = $icon;
80+
81+
return $this;
82+
}
83+
84+
public function unsubscribeIcon(Closure|string $icon): static
85+
{
86+
$this->unsubscribeIconOverride = $icon;
87+
88+
return $this;
89+
}
90+
91+
public function subscribeColor(Closure|string $color, string $context = 'action'): static
92+
{
93+
$this->subscriptionColorOverrides[$context]['subscribe'] = $color;
94+
95+
return $this;
96+
}
97+
98+
public function unsubscribeColor(Closure|string $color, string $context = 'action'): static
99+
{
100+
$this->subscriptionColorOverrides[$context]['unsubscribe'] = $color;
101+
102+
return $this;
103+
}
104+
63105
protected function resolveCurrentUser(): ?Commenter
64106
{
65107
return Config::resolveAuthenticatedUser();
@@ -110,50 +152,8 @@ protected function computeSubscriptionColor(Model $record, string $context = 'ac
110152
return $this->evaluateSubscriptionOverride($this->subscriptionColorOverrides[$context]['subscribe'] ?? null, $record) ?? ($context === 'table' ? 'primary' : 'gray');
111153
}
112154

113-
public function subscribeLabel(Closure|string $label): static
114-
{
115-
$this->subscribeLabelOverride = $label;
116-
117-
return $this;
118-
}
119-
120-
public function unsubscribeLabel(Closure|string $label): static
121-
{
122-
$this->unsubscribeLabelOverride = $label;
123-
124-
return $this;
125-
}
126-
127-
public function subscribeIcon(Closure|string $icon): static
128-
{
129-
$this->subscribeIconOverride = $icon;
130-
131-
return $this;
132-
}
133-
134-
public function unsubscribeIcon(Closure|string $icon): static
135-
{
136-
$this->unsubscribeIconOverride = $icon;
137-
138-
return $this;
139-
}
140-
141-
public function subscribeColor(Closure|string $color, string $context = 'action'): static
142-
{
143-
$this->subscriptionColorOverrides[$context]['subscribe'] = $color;
144-
145-
return $this;
146-
}
147-
148-
public function unsubscribeColor(Closure|string $color, string $context = 'action'): static
149-
{
150-
$this->subscriptionColorOverrides[$context]['unsubscribe'] = $color;
151-
152-
return $this;
153-
}
154-
155155
/**
156-
* @param (Closure(Model): string)|string|null $override
156+
* @param (Closure(Model): string)|string|null $override
157157
*/
158158
protected function evaluateSubscriptionOverride(Closure|string|null $override, Model $record): ?string
159159
{
@@ -164,10 +164,6 @@ protected function evaluateSubscriptionOverride(Closure|string|null $override, M
164164
return $override;
165165
}
166166

167-
/**
168-
*
169-
* @return bool|null
170-
*/
171167
protected function toggleSubscriptionForRecord(Model $record): ?bool
172168
{
173169
$user = $this->resolveCurrentUser();

src/Livewire/Concerns/HasSidebar.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,3 @@ protected function getCurrentUser(): ?Commenter
9494
return Config::resolveAuthenticatedUser();
9595
}
9696
}
97-
98-

src/Livewire/SubscriptionSidebar.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,3 @@ public function render()
2323
return view('commentions::subscription-sidebar');
2424
}
2525
}
26-
27-

tests/Livewire/CommentsSubscriptionTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555
livewire(Comments::class, [
5656
'record' => $post,
5757
])->assertSet('isSubscribed', false)
58-
->assertSet('subscribers', fn ($subscribers) => $subscribers instanceof \Illuminate\Support\Collection && $subscribers->isEmpty());
58+
->assertSet('subscribers', fn ($subscribers) => $subscribers instanceof \Illuminate\Support\Collection && $subscribers->isEmpty());
5959

6060
$post->subscribe($user);
6161

6262
livewire(Comments::class, [
6363
'record' => $post,
6464
])->assertSet('isSubscribed', true)
65-
->assertSet('subscribers', fn ($subscribers) => $subscribers->contains('id', $user->id));
65+
->assertSet('subscribers', fn ($subscribers) => $subscribers->contains('id', $user->id));
6666
});
6767

6868
test('toggleSubscription subscribes and unsubscribes the current user', function () {
@@ -78,7 +78,7 @@
7878
livewire(Comments::class, [
7979
'record' => $post,
8080
])->call('toggleSubscription')
81-
->assertSet('isSubscribed', true);
81+
->assertSet('isSubscribed', true);
8282

8383
expect(CommentSubscription::query()->where([
8484
'subscribable_type' => $post->getMorphClass(),
@@ -90,7 +90,7 @@
9090
livewire(Comments::class, [
9191
'record' => $post,
9292
])->call('toggleSubscription')
93-
->assertSet('isSubscribed', false);
93+
->assertSet('isSubscribed', false);
9494

9595
expect(CommentSubscription::query()->where([
9696
'subscribable_type' => $post->getMorphClass(),
@@ -113,5 +113,3 @@
113113
'record' => $post,
114114
])->assertSet('showSubscribers', false);
115115
});
116-
117-

0 commit comments

Comments
 (0)