Passed
Push — master ( 46427f...5263c8 )
by Burak
07:19
created

PushNotificationForm::pushNotification()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Http\Livewire\Data;
4
5
use App\Interfaces\MessageServiceInterface;
6
use App\Models\Message;
7
use Illuminate\Support\Facades\Auth;
8
use Livewire\Component;
9
10
class PushNotificationForm extends Component
11
{
12
    public function pushNotification(MessageServiceInterface $messageService)
13
    {
14
        $subject = 'PING '.now();
15
        $message = Message::factory()->make();
16
        $messageService->newThread($subject, Auth::user(), $message->body);
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Facades\Auth::user() can also be of type null; however, parameter $user of App\Interfaces\MessageSe...eInterface::newThread() does only seem to accept App\Models\User, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

16
        $messageService->newThread($subject, /** @scrutinizer ignore-type */ Auth::user(), $message->body);
Loading history...
17
    }
18
19
    public function render()
20
    {
21
        return view('livewire.data.push-notification-form');
22
    }
23
}
24