Completed
Push — master ( 002bc5...c06b9c )
by Julien
08:45
created

ApiController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 4
c 2
b 0
f 2
lcom 0
cbo 3
dl 0
loc 59
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A categories() 0 16 2
A actors() 0 17 2
1
<?php
2
3
namespace App\Http\Controllers;
4
use App\Http\Models\Actors;
5
use App\Http\Models\Categories;
6
use App\Http\Models\Comments;
7
use App\Http\Models\Movies;
8
use App\Http\Models\Sessions;
9
use App\Http\Models\User;
10
use Illuminate\Support\Facades\DB;
11
12
13
/**
14
 * Class ApiController
15
 * @package App\Http\Controllers
16
 * Sufficé par le mot clef Controller
17
 * et doit hérité de la super classe Controller
18
 */
19
class ApiController extends Controller{
20
21
22
    /**
23
     * Me retournera mes données de catégorie
24
     */
25
    public function categories(){
26
27
        $tab = [];
28
        $categories = Categories::all();
29
30
        foreach($categories as $categorie){
31
            $tab[] =
32
                [
33
                    $categorie->title,
34
                    count($categorie->movies)
35
                ];
36
        }
37
38
        return $tab;
39
40
    }
41
42
43
    /**
44
     * [{
45
    name: 'Toronto',
46
    data: [15]
47
    }, {
48
    name: 'Paris',
49
    data: [120]
50
    }, {
51
    name: 'Facebook',
52
    data: [90]
53
    }, {
54
    name: 'Dribble',
55
    data: [120]
56
    }]
57
     */
58
    public function actors(){
59
60
        $obj = new Actors();
61
        $resultat = $obj->getNbActorsByCity();
62
63
        //exit(dump($resultat));
0 ignored issues
show
Unused Code Comprehensibility introduced by
88% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
64
65
        $tab = [];
66
        foreach($resultat as $actor){
67
            $tab[] = [
68
                "name" => $actor->city,
69
                "data" => [(int)$actor->nb],
70
            ];
71
        }
72
73
        return $tab ;
74
    }
75
76
77
}
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96