ApiController::categories()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 15
rs 9.4285
cc 2
eloc 8
nc 2
nop 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Models\Actors;
6
use App\Http\Models\Categories;
7
8
/**
9
 * Class ApiController.
10
 */
11
class ApiController extends Controller
12
{
13
14
    /**
15
     * Me retournera mes données de catégorie.
16
     */
17
    public function categories()
18
    {
19
        $tab = [];
20
        $categories = Categories::all();
21
22
        foreach ($categories as $categorie) {
23
            $tab[] =
24
                [
25
                    $categorie->title,
26
                    count($categorie->movies),
27
                ];
28
        }
29
30
        return $tab;
31
    }
32
33
    /**
34
     * Get Actors.
35
     *
36
     * @return array
37
     */
38
    public function actors()
39
    {
40
        $obj = new Actors();
41
        $resultat = $obj->getNbActorsByCity();
42
43
        //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...
44
45
        $tab = [];
46
        foreach ($resultat as $actor) {
47
            $tab[] = [
48
                'name' => $actor->city,
49
                'data' => [(int) $actor->nb],
50
            ];
51
        }
52
53
        return $tab;
54
    }
55
}
56