Passed
Push — main ( ee7bfe...8f061d )
by Karl
05:56
created

DeckApiController::shuffle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace App\Controller;
4
5
use App\Service\DeckService;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\Routing\Attribute\Route;
10
11
class DeckApiController extends AbstractController
12
{
13
    public function __construct(protected DeckService $deckService)
14
    {
15
    }
16
17
    #[Route('/api/deck', name: 'api_deck', defaults: ['deck_needed' => true ])]
18
    public function deck(Request $request): JsonResponse
19
    {
20
        $deck = $this->deckService->getDeck($request);
21
        return $deck;
22
    }
23
24
    #[Route('/api/deck/shuffle', name: 'api_deck_shuffle', defaults: ['deck_needed' => true ])]
25
    public function shuffle(Request $request): JsonResponse
26
    {
27
        $deck = $this->deckService->shuffleDeck($request);
28
        return $deck;
29
    }
30
31
    #[Route('/api/deck/draw', name: 'api_deck_draw', defaults: ['deck_needed' => true ])]
32
    public function draw(Request $request): JsonResponse
33
    {
34
        $deck = $this->deckService->drawCard($request);
35
        return $deck;
36
    }
37
38
    #[Route('/api/deck/draw/{number}', name: 'api_deck_draw_number', defaults: ['deck_needed' => true ])]
39
    public function drawNumber(int $number, Request $request): JsonResponse
40
    {
41
        $deck = $this->deckService->drawCards($number, $request);
42
        return $deck;
43
    }
44
45
    #[Route('/api/deck/deal/{players}/{cards}', name: 'api_deck_deal', defaults: ['deck_needed' => true ])]
46
    public function deal(int $players, int $cards, Request $request): JsonResponse
47
    {
48
        $deck = $this->deckService->dealCards($players, $cards, $request);
49
        return $deck;
50
    }
51
52
    #[Route('/api/deck/reset', name: 'api_deck_reset', defaults: ['deck_needed' => true ])]
53
    public function reset(Request $request): JsonResponse
54
    {
55
        $deck = $this->deckService->resetDeck($request);
56
        return $deck;
57
    }
58
}
59