Completed
Push — master ( 7a6d93...c42c77 )
by Phan
08:43
created

PlayCountController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 4
cp 0.75
rs 10
cc 1
nc 1
nop 1
crap 1.0156
1
<?php
2
3
namespace App\Http\Controllers\API\Interaction;
4
5
use App\Events\SongStartedPlaying;
6
use App\Http\Requests\API\Interaction\StorePlayCountRequest;
7
use Illuminate\Http\JsonResponse;
8
9
/**
10
 * @group 3. Song interactions
11
 */
12
class PlayCountController extends Controller
13
{
14
    /**
15
     * Increase play count.
16
     *
17
     * Increase a song's play count as the currently authenticated user.
18
     * This request should be made whenever a song is played.
19
     * An "interaction" record including the song and current user's data will be returned.
20
     *
21
     * @bodyParam song string required The ID of the song. Example: 0146d01afb742b01f28ab8b556f9a75d
22
     *
23
     * @responseFile responses/interaction.json
24
     *
25
     * @return JsonResponse
26
     */
27 1
    public function store(StorePlayCountRequest $request)
28
    {
29 1
        $interaction = $this->interactionService->increasePlayCount($request->song, $request->user());
30 1
        $this->dispatch(new SongStartedPlaying($interaction->song, $interaction->user));
31
32
        return response()->json($interaction);
33
    }
34
}
35