| Conditions | 1 |
| Paths | 1 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | #[Route("/api/quote", name: "quote")] |
||
| 25 | public function jsonQuote(): JsonResponse |
||
| 26 | { |
||
| 27 | $quotes = [ |
||
| 28 | 0 => "The early bird might get the worm, but the late bird gets to sleep in and have pancakes for breakfast.", |
||
| 29 | 1 => "I have always said that the key to happiness is a good pair of fuzzy socks and a tub of ice cream.", |
||
| 30 | 2 => "Always remember, when in doubt, hug a tree and it will give you the answer to any question you may have." |
||
| 31 | ]; |
||
| 32 | |||
| 33 | $randKey = array_rand($quotes, 1); |
||
| 34 | |||
| 35 | $data = [ |
||
| 36 | 'quote' => $quotes[$randKey], |
||
| 37 | 'date' => date('l jS \of F Y G:i:s'), |
||
| 38 | ]; |
||
| 39 | |||
| 40 | $response = new JsonResponse($data); |
||
| 41 | $response->setEncodingOptions( |
||
| 42 | $response->getEncodingOptions() | JSON_PRETTY_PRINT |
||
| 43 | ); |
||
| 44 | return $response; |
||
| 45 | } |
||
| 47 |