Passed
Push — develop ( fc9ba3...3655e4 )
by Nikita
04:54
created

GamesController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
eloc 13
c 0
b 0
f 0
dl 0
loc 51
ccs 0
cts 4
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 5 1
A destroy() 0 5 1
A store() 0 5 1
A __construct() 0 5 1
A show() 0 3 1
A index() 0 5 1
1
<?php
2
3
namespace Gameap\Http\Controllers\API;
4
5
use Gameap\Http\Controllers\AuthController;
6
use Gameap\Models\Game;
7
use Gameap\Repositories\GameRepository;
8
use Illuminate\Http\Request;
9
10
class GamesController extends AuthController
11
{
12
    /**
13
     * The GameRepository instance.
14
     *
15
     * @var \Gameap\Repositories\GameRepository
16
     */
17
    public $repository;
18
19
    /**
20
     * GamesController constructor.
21
     * @param GameRepository $repository
22
     */
23
    public function __construct(GameRepository $repository)
24
    {
25
        parent::__construct();
26
27
        $this->repository = $repository;
28
    }
29
30
    public function index()
31
    {
32
        $games = Game::all();
33
34
        return response()->json($games);
35
    }
36
37
    public function store(Request $request)
38
    {
39
        $game = Game::create($request->all());
40
41
        return response()->json($game, 201);
42
    }
43
44
    public function show(Game $game)
45
    {
46
        return response()->json($game);
47
    }
48
49
    public function update(Request $request, Game $game)
50
    {
51
        $game->update($request->all());
52
53
        return response()->json($game, 200);
54
    }
55
56
    public function destroy(Game $game)
57
    {
58
        $game->delete();
59
60
        return response()->json(null, 204);
61
    }
62
}
63