ClickController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 14
c 0
b 0
f 0
rs 10
ccs 6
cts 6
cp 1
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 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