ApiController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 36
c 3
b 0
f 0
dl 0
loc 59
ccs 0
cts 45
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assadsQuotes() 0 6 1
A index() 0 45 1
A __construct() 0 2 1
1
<?php
2
3
namespace App\Controller;
4
5
use App\Service\QuoteService;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\Routing\Attribute\Route;
10
11
class ApiController extends AbstractController
12
{
13
    public function __construct(protected QuoteService $quoteService)
14
    {
15
    }
16
17
    #[Route('/api', name: 'app_api')]
18
    public function index(): Response
19
    {
20
21
        $data = [
22
            'api' => [
23
                'api_currency' => [
24
                    'path' => '/api/currency',
25
                    'description' => 'Provides a list of currencies.'
26
                ],
27
                'api_game' => [
28
                'path' => '/api/game',
29
                'description' => 'Provides the current state of the game.'
30
                ],
31
                'api_quotes' => [
32
                'path' => '/api/quote',
33
                '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.'
34
                ],
35
                'api_deck' => [
36
                'path' => '/api/deck',
37
                'description' => 'Provides a French-suited deck of cards, sorted by suit and value.'
38
                ],
39
                'api_deck_shuffle' => [
40
                'path' => '/api/deck/shuffle',
41
                'description' => 'Shuffles the French-suited deck of cards.'
42
                ],
43
                'api_deck_draw' => [
44
                'path' => '/api/deck/draw',
45
                'description' => 'Draws one card from the French-suited deck of cards.'
46
                ],
47
                'api_deck_draw_number/4' => [
48
                'path' => '/api/deck/draw/{number}',
49
                'description' => 'Draws a specified number of cards from the French-suited deck of cards.'
50
                ],
51
                'api_deck_deal' => [
52
                'path' => '/api/deck/deal/{players}/{cards}',
53
                'description' => 'Deals a specified number of cards to a specified number of players from the French-suited deck of cards.'
54
                ],
55
                'api_deck_reset' => [
56
                'path' => '/api/deck/reset',
57
                'description' => 'Resets the French-suited deck of cards.'
58
                ]
59
            ]
60
        ];
61
        return $this->render('api/index.html.twig', $data);
62
    }
63
64
    #[Route('/api/quote', name: 'app_quotes')]
65
    #[Route('/api/quote', name: 'api_quotes')]
66
    public function assadsQuotes(): JsonResponse
67
    {
68
        $quote = $this->quoteService->getAssadsQuote();
69
        return $quote;
70
    }
71
}
72