TrackClicksController::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 3
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