add solutions for chapter 10
This commit is contained in:
parent
d880aeb9a6
commit
e91a166816
18 changed files with 1872 additions and 0 deletions
24
implementation/10/src/Action/Hello.php
Normal file
24
implementation/10/src/Action/Hello.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Action;
|
||||
|
||||
use Lubian\NoFramework\Service\Time\Clock;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class Hello
|
||||
{
|
||||
public function __invoke(
|
||||
ResponseInterface $response,
|
||||
Clock $clock,
|
||||
string $name = 'Stranger'
|
||||
): ResponseInterface
|
||||
{
|
||||
$body = $response->getBody();
|
||||
|
||||
$body->write('Hello ' . $name . '!<br />');
|
||||
$body->write('The time is: ' . $clock->now()->format('H:i:s'));
|
||||
|
||||
return $response->withBody($body)
|
||||
->withStatus(200);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue