| Conditions | 1 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | #[Route("/api/game", name: 'json-game', methods: ['GET'], defaults: ['description' => 'Returnerar en JSON-struktur med den aktuella ställningen för spelet.'])] |
||
| 17 | public function game( |
||
| 18 | SessionInterface $session |
||
| 19 | ): Response { |
||
| 20 | // Hämta spelomgång från session |
||
| 21 | /** @var Game $game */ |
||
| 22 | $game = $session->get('game'); |
||
| 23 | |||
| 24 | // Returnerar aktuell ställning som JSON-struktur |
||
| 25 | $data = [ |
||
| 26 | "playerScore" => $game->getPlayerScore(), |
||
| 27 | "bankScore" => $game->getBankScore() |
||
| 28 | ]; |
||
| 29 | |||
| 30 | $response = new JsonResponse($data); |
||
| 31 | $response->setEncodingOptions( |
||
| 32 | $response->getEncodingOptions() | JSON_PRETTY_PRINT |
||
| 33 | ); |
||
| 34 | return $response; |
||
| 35 | } |
||
| 37 |