| Conditions | 1 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | #[Route("/api/quote")] |
||
| 12 | public function jsonNumber(): Response |
||
| 13 | { |
||
| 14 | $quoteList = [ |
||
| 15 | "Life is like riding a bicycle. To keep your balance, you must keep moving forward.", |
||
| 16 | "Its never too late to give up.", |
||
| 17 | "Theres no such thing as bad weather, only inappropriate clothing." |
||
| 18 | ]; |
||
| 19 | $randomIndex = random_int(0, count($quoteList) - 1); |
||
| 20 | $randomQuote = $quoteList[$randomIndex]; |
||
| 21 | |||
| 22 | $data = [ |
||
| 23 | 'quote' => $randomQuote, |
||
| 24 | 'date' => date('Y-m-d'), |
||
| 25 | 'timestamp' => date('H:i:s') |
||
| 26 | ]; |
||
| 27 | |||
| 28 | $response = new JsonResponse($data); |
||
| 29 | $response->setEncodingOptions( |
||
| 30 | $response->getEncodingOptions() | JSON_PRETTY_PRINT |
||
| 31 | ); |
||
| 32 | |||
| 33 | return $response; |
||
| 34 | } |
||
| 36 |