TrackClicksController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 2
1
<?php
2
3
namespace Spatie\EmailCampaigns\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Spatie\EmailCampaigns\Jobs\RegisterClickJob;
7
8
class TrackClicksController
9
{
10
    public function __invoke(Request $request, string $campaignLinkUuid, string $campaignSendUuid)
11
    {
12
        if (! is_null($campaignSendUuid)) {
13
            dispatch(new RegisterClickJob($campaignLinkUuid, $campaignSendUuid));
14
        }
15
16
        $redirectUrl = $request->input('redirect');
17
18
        return redirect()->to($redirectUrl);
0 ignored issues
show
Bug introduced by
It seems like $redirectUrl defined by $request->input('redirect') on line 16 can also be of type array or null; however, Illuminate\Routing\Redirector::to() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
19
    }
20
}
21