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

ApiController::reset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
nc 1
nop 1
dl 0
loc 5
c 0
b 0
f 0
cc 1
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Controller;
4
5
use App\Service\QuoteService;
6
use App\Service\DeckService;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\HttpFoundation\JsonResponse;
11
use Symfony\Component\Routing\Attribute\Route;
12
13
class ApiController extends AbstractController
14
{
15
    public function __construct(protected QuoteService $quoteService)
16
    {
17
    }
18
19
    #[Route('/api', name: 'app_api')]
20
    public function index(): Response
21
    {
22
23
        $data = [
24
            'api' => [
25
                'api_currency' => [
26
                    'path' => '/api/currency',
27
                    'description' => 'Provides a list of currencies.'
28
                ],
29
                'api_game' => [
30
                'path' => '/api/game',
31
                'description' => 'Provides the current state of the game.'
32
                ],
33
                'api_quotes' => [
34
                'path' => '/api/quote',
35
                'description' => 'Provides paraphrased quotes, written by chatGPT, from a fictional character named Assad. The quotes are based on a book series called Department Q by Jussi Adler-Olsen.'
36
                ],
37
                'api_deck' => [
38
                'path' => '/api/deck',
39
                'description' => 'Provides a French-suited deck of cards, sorted by suit and value.'
40
                ],
41
                'api_deck_shuffle' => [
42
                'path' => '/api/deck/shuffle',
43
                'description' => 'Shuffles the French-suited deck of cards.'
44
                ],
45
                'api_deck_draw' => [
46
                'path' => '/api/deck/draw',
47
                'description' => 'Draws one card from the French-suited deck of cards.'
48
                ],
49
                'api_deck_draw_number/4' => [
50
                'path' => '/api/deck/draw/{number}',
51
                'description' => 'Draws a specified number of cards from the French-suited deck of cards.'
52
                ],
53
                'api_deck_deal' => [
54
                'path' => '/api/deck/deal/{players}/{cards}',
55
                'description' => 'Deals a specified number of cards to a specified number of players from the French-suited deck of cards.'
56
                ],
57
                'api_deck_reset' => [
58
                'path' => '/api/deck/reset',
59
                'description' => 'Resets the French-suited deck of cards.'
60
                ]
61
            ]
62
        ];
63
        return $this->render('api/index.html.twig', $data);
64
    }
65
66
    #[Route('/api/quote', name: 'app_quotes')]
67
    #[Route('/api/quote', name: 'api_quotes')]
68
    public function assadsQuotes(): JsonResponse
69
    {
70
        $quote = $this->quoteService->getAssadsQuote();
71
        return $quote;
72
    }
73
}
74