explain implementation of ad-hoc depencency container
This commit is contained in:
parent
7a1ce1cad1
commit
8c0cd56191
8 changed files with 297 additions and 250 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue