PlayCountController::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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
        event(new SongStartedPlaying($interaction->song, $interaction->user));
31
32 1
        return response()->json($interaction);
33
    }
34
}
35