CommentController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 1
c 2
b 0
f 1
lcom 0
cbo 2
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 1
1
<?php
2
3
namespace LearnParty\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use LearnParty\Http\Requests;
7
use Auth;
8
9
class CommentController extends Controller
10
{
11
    /**
12
     * Add a new comment to a video
13
     *
14
     * @param  Request $request
15
     * @return array success or failure message
16
     */
17
    public function create(Request $request)
18
    {
19
        $this->validate($request, [
20
            'comment' => 'required|max:500',
21
        ]);
22
        $newComment = Auth::user()->comments()->create($request->all());
0 ignored issues
show
Unused Code introduced by
$newComment 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...
23
        return [
24
            'status' => 200,
25
            'message' => 'New comment succesfully added.'
26
        ];
27
    }
28
}
29