Test Setup Failed
Push — master ( 7ec5cf...f827c6 )
by Phan
04:13
created

PlayCountController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A store() 0 9 2
1
<?php
2
3
namespace App\Http\Controllers\API\Interaction;
4
5
use App\Events\SongStartedPlaying;
6
use App\Models\Interaction;
7
use Illuminate\Http\JsonResponse;
8
use Illuminate\Http\Request;
9
10
class PlayCountController extends Controller
11
{
12
    /**
13
     * Increase a song's play count as the currently authenticated user.
14
     *
15
     * @param Request $request
16
     *
17
     * @return JsonResponse
18
     */
19
    public function store(Request $request)
20
    {
21
        $interaction = Interaction::increasePlayCount($request->song, $request->user());
22
        if ($interaction) {
23
            event(new SongStartedPlaying($interaction->song, $interaction->user));
24
        }
25
26
        return response()->json($interaction);
27
    }
28
}
29