CommentController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 5
c 4
b 0
f 0
dl 0
loc 23
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A presenceRegister() 0 4 2
A showTyping() 0 4 2
1
<?php
2
3
namespace FaithGen\SDK\Http\Controllers;
4
5
use FaithGen\SDK\Events\Commenter\TypingRegistered;
6
use FaithGen\SDK\Events\Commenter\UserPresent;
7
use FaithGen\SDK\Http\Requests\PresenceRegistryRequest;
8
use Illuminate\Routing\Controller;
9
10
class CommentController extends Controller
11
{
12
    /**
13
     * Shows other users when one is joining or leaving the discussion.
14
     *
15
     * @param  PresenceRegistryRequest  $request
16
     */
17
    public function presenceRegister(PresenceRegistryRequest $request)
18
    {
19
        if (! config('faithgen-sdk.source')) {
20
            event(new UserPresent(auth('web')->user(), $request->validated()));
0 ignored issues
show
Bug introduced by
It seems like auth('web')->user() can also be of type null; however, parameter $user of FaithGen\SDK\Events\Comm...rPresent::__construct() does only seem to accept FaithGen\SDK\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

20
            event(new UserPresent(/** @scrutinizer ignore-type */ auth('web')->user(), $request->validated()));
Loading history...
21
        }
22
    }
23
24
    /**
25
     * Registers to other users when one is typing a comment.
26
     *
27
     * @param  PresenceRegistryRequest  $request
28
     */
29
    public function showTyping(PresenceRegistryRequest $request)
30
    {
31
        if (! config('faithgen-sdk.source')) {
32
            event(new TypingRegistered(auth('web')->user(), $request->validated()));
0 ignored issues
show
Bug introduced by
It seems like auth('web')->user() can also be of type null; however, parameter $user of FaithGen\SDK\Events\Comm...gistered::__construct() does only seem to accept FaithGen\SDK\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

32
            event(new TypingRegistered(/** @scrutinizer ignore-type */ auth('web')->user(), $request->validated()));
Loading history...
33
        }
34
    }
35
}
36