explain implementation of ad-hoc depencency container

This commit is contained in:
lubiana 2022-05-21 00:53:33 +02:00
parent 7a1ce1cad1
commit 8c0cd56191
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
8 changed files with 297 additions and 250 deletions

View file

@ -2,7 +2,6 @@
namespace Lubian\NoFramework\Action;
use Lubian\NoFramework\Service\Time\Clock;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@ -13,8 +12,7 @@ final class Hello implements RequestHandlerInterface
public function __construct(
private readonly ResponseInterface $response,
private readonly Clock $clock
)
{
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
@ -22,7 +20,8 @@ final class Hello implements RequestHandlerInterface
$name = $request->getAttribute('name', 'Stranger');
$body = $this->response->getBody();
$time = $this->clock->now()->format('H:i:s');
$time = $this->clock->now()
->format('H:i:s');
$body->write('Hello ' . $name . '!<br />');
$body->write('The Time is: ' . $time);