VideoController   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 7
c 4
b 0
f 2
lcom 0
cbo 6
dl 67
loc 67
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A index() 5 5 1
A new_review() 4 4 1
A create() 8 8 1
A edit() 6 6 1
A update() 8 8 1
A delete() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace WITR\Http\Controllers\Admin;
2
3
use WITR\Http\Requests\Admin\Video as Requests;
4
use WITR\Http\Controllers\Controller;
5
use WITR\Video;
6
use Input;
7
8
use Illuminate\Http\Request;
9
10 View Code Duplication
class VideoController extends Controller {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
12
	public function __construct()
13
	{
14
		$this->middleware('auth');
15
		$this->middleware('editor');
16
	}
17
18
	/**
19
	 * Display a listing of the Videos.
20
	 *
21
	 * @return Response
22
	 */
23
	public function index()
24
	{
25
		$videos = Video::orderBy('artist', 'asc')->get();
26
		return view('admin.videos.index', ['videos' => $videos]);
27
	}
28
29
	/**
30
	 * Display a listing of the resource.
31
	 *
32
	 * @return Response
33
	 */
34
	public function new_review()
35
	{
36
		return view('admin.videos.create');
37
	}
38
39
	/**
40
	* Save the new eboard position.
41
	*
42
	*@return Response
43
	*/
44
	public function create(Requests\CreateRequest $request)
45
	{
46
		$input = $request->all();
47
		$video = new Video($input);
48
		$video->save();
49
		return redirect()->route('admin.videos.index')
50
			->with('success', 'Video Review Saved!');
51
	}
52
53
	public function edit($id)
54
	{
55
		$video = Video::findOrFail($id);
56
57
		return view('admin.videos.edit', ['video' => $video]);
58
	}
59
60
	public function update(Requests\UpdateRequest $request, $id)
61
	{
62
		$video = Video::findOrFail($id);
63
		$video->fill($request->all());
64
		$video->save();
65
		return redirect()->route('admin.videos.index')
66
			->with('success', 'Video Review Saved!');
67
	}
68
69
	public function delete($id)
70
	{
71
		Video::destroy($id);
72
		return redirect()->route('admin.videos.index')
73
			->with('success', 'Video Review Deleted!');
74
	}
75
76
}
77