request-model
request-model copied to clipboard
Why does method RequestModelFactory::getRequestData() return an array and not a DTO?
namespace Yiisoft\RequestModel;
final class RequestModelFactory
{
private function getRequestData(ServerRequestInterface $request): array
{
return [
'query' => $request->getQueryParams(),
'body' => $request->getParsedBody(),
'attributes' => $request->getAttributes(),
'headers' => $request->getHeaders(),
'files' => $request->getUploadedFiles(),
'cookie' => $request->getCookieParams(),
'router' => $this->currentRoute->getArguments(),
];
}
}
What's the benefit of using DTO here?
The transparency
- of the IDE code will quickly show where the value was set
- the entire list of properties is visible
I like this idea.