Completed
Push — master ( f00659...1f4cdd )
by Julien
05:36
created

Movies   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 82
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 4
Bugs 0 Features 4
Metric Value
wmc 8
c 4
b 0
f 4
lcom 1
cbo 1
dl 82
loc 82
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllMovies() 6 6 1
A getAvgNotePresse() 8 8 1
A categories() 4 4 1
A actors() 4 4 1
A directors() 4 4 1
A comments() 4 4 1
A sessions() 4 4 1
A recommandations() 4 4 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\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\DB;
7
8
9
/**
10
 * Classe qui va stocker mes requetes autoirs
11
 * de ma table movies
12
 * Hérite de ma super classe Model
13
 */
14 View Code Duplication
class Movies extends Model{
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...
15
16
17
    /**
18
     * Décrit le nom de la table
19
     * que classe fait référence
20
     */
21
    protected $table = 'movies';
22
23
24
25
    /**
26
     *  Retourne tous les films
27
     */
28
    public function getAllMovies(){
29
30
        // retourne le resultat de ma requete SELECT * FROM movies
31
        return DB::table('movies')->get();
32
33
    }
34
35
36
    /**
37
     * Return moyenne des notes de presse
38
     */
39
    public function getAvgNotePresse(){
40
        $result = DB::table('movies')
41
                ->select(DB::raw("ROUND(AVG(note_presse)) as avgpress"))
42
                ->first();
43
44
        return $result;
45
46
    }
47
48
    /***************************************************** Relationships ***********************************************************/
49
50
51
    /**
52
     * Retourne la catégorie à laquelle appartient un objet film
53
     * Many To One : n..1
54
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
55
     */
56
    public function categories()
57
    {
58
        return $this->belongsTo('App\Http\Models\Categories');
59
    }
60
61
    /**
62
     * belongsToMany(): Many To Many
63
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
64
     */
65
    public function actors()
66
    {
67
        return $this->belongsToMany('App\Http\Models\Actors');
68
    }
69
70
    public function directors()
71
    {
72
        return $this->belongsToMany('App\Http\Models\Directors');
73
    }
74
75
    public function comments()
76
    {
77
        return $this->hasMany('App\Http\Models\Comments');
78
    }
79
80
    public function sessions()
81
    {
82
        return $this->hasMany('App\Http\Models\Sessions');
83
    }
84
85
    public function recommandations()
86
    {
87
        return $this->hasMany('App\Http\Models\Recommandations');
88
    }
89
90
91
92
93
94
95
}
96
97
98
99