ClickController::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 5
nc 3
nop 1
dl 0
loc 12
c 0
b 0
f 0
cc 3
rs 10
ccs 6
cts 6
cp 1
crap 3
1
<?php
2
3
namespace NotificationTracker\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Routing\Controller;
7
use Illuminate\Support\Facades\Response;
8
use NotificationTracker\Models\TrackedChannel;
9
use NotificationTracker\NotificationTracker;
10
11
class ClickController extends Controller
12
{
13 2
    public function __invoke(Request $request)
14
    {
15 2
        if ($uuid = $request->route('uuid', '')) {
16
            // TODO: move to queue job to speed up updating?
17
            /** @var TrackedChannel $tracker */
18 2
            $tracker = NotificationTracker::modelClass('channel')::query()->uuid($uuid)->first();
19 2
            if ($tracker) {
0 ignored issues
show
introduced by
$tracker is of type NotificationTracker\Models\TrackedChannel, thus it always evaluated to true.
Loading history...
20 1
                $tracker->incrementClick()->save();
21
            }
22
        }
23
24 2
        return Response::redirectTo($request->input(NotificationTracker::clickTrackerUrlParameterName(), '/'));
25
    }
26
}
27