Passed
Push — develop ( dfa246...179c36 )
by Francisco
02:27
created

CourseController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 61.11 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 11
loc 18
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 11 11 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
2
3
namespace App\Http\Controllers;
4
5
use App\Judite\Models\Course;
6
use Illuminate\Support\Facades\DB;
7
8
class CourseController extends Controller
9
{
10
    /**
11
     * Display a listing of the resource.
12
     *
13
     * @return \Illuminate\Http\Response
14
     */
15 View Code Duplication
    public function index()
0 ignored issues
show
Duplication introduced by
This method 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...
16
    {
17
        $courses = DB::transaction(function () {
18
            return Course::orderedList()->get();
19
        });
20
21
        $courses = $courses->groupBy(function ($course) {
22
            return $course->present()->getOrdinalYear();
23
        });
24
25
        return view('courses.index', compact('courses'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('courses.index', compact('courses')) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
26
    }
27
}
28