This repository was archived by the owner on Aug 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 44
55namespace App \Controller ;
66
7+ use App \Repository \LastUpdateRepository ;
78use Symfony \Component \HttpFoundation \Response ;
89
910final class DefaultController
1011{
12+ public function __construct (
13+ private LastUpdateRepository $ repository ,
14+ ) {
15+ }
16+
1117 public function index (): Response
1218 {
19+ $ lastUpdate = $ this ->repository ->get ()->format ('Y-m-d H:i:s ' );
20+
1321 return new Response (<<<HTML
1422<html>
1523 <head>
1624 <title>phpversions</title>
1725 </head>
1826 <body>
19- An API that expose all PHP versions:
27+ <p> An API that expose all PHP versions:</p>
2028 <ul>
2129 <li><a href="/all.json">All main PHP versions</a></li>
2230 <li><a href="/releases.json">All PHP releases versions</a></li>
2331 <li><a href="/current.json">Maintened versions</a></li>
2432 <li><a href="/eol.json">Unmainted versions</a></li>
2533 </ul>
34+ <p>Last update: $ lastUpdate</p>
2635 </body>
2736</html>
2837HTML
Original file line number Diff line number Diff line change @@ -17,6 +17,13 @@ public function __construct(
1717 ) {
1818 }
1919
20+ public function get (): DateTimeImmutable
21+ {
22+ $ stmt = $ this ->db ->query ('SELECT * FROM last_update; ' );
23+
24+ return new DateTimeImmutable ($ stmt ->fetchColumn ());
25+ }
26+
2027 public function save (): void
2128 {
2229 $ this ->db ->beginTransaction ();
You can’t perform that action at this time.
0 commit comments