NotificationController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 11 1
A update() 0 18 3
1
<?php
2
3
namespace Tracking\Http\Controllers\Metrics;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Routing\Controller;
7
use Tracking\Models\Metrics\LarametricsNotification;
8
9
class NotificationController extends Controller
10
{
11
    
12
    public function index()
13
    {
14
        $notifications = LarametricsNotification::all();
15
        
16
        return view(
17
            'rica.larametrics::notifications.index', [
18
            'notifications' => $notifications,
19
            'pageTitle' => 'Notifications'
20
            ]
21
        );
22
    }
23
24
    public function update(Request $request)
25
    {
26
        $notifications = '';
0 ignored issues
show
Unused Code introduced by
$notifications is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
27
        LarametricsNotification::truncate();
28
        foreach(json_decode($request->input('notifications')) as $notification) {
29
            $notificationData = array(
30
                'action' => $notification->action,
31
                'filter' => $notification->filter,
32
                'notify_by' => $notification->notify_by
33
            );
34
            try {
35
                LarametricsNotification::create($notificationData);
36
            } catch(\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
37
            }
38
        }
39
40
        return redirect()->route('rica.larametrics::notifications.index');
41
    }
42
43
}
44