Zend\Diactoros\Request\Serializer::fromString PHP Метод

fromString() публичный статический Метод

Internally, casts the message to a stream and invokes fromStream().
public static fromString ( string $message ) : Request
$message string
Результат Zend\Diactoros\Request
    public static function fromString($message)
    {
        $stream = new Stream('php://temp', 'wb+');
        $stream->write($message);
        return self::fromStream($stream);
    }

Usage Example

 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     if ($request->getMethod() === 'POST') {
         $parsedBody = $this->parseBody($request->getBody());
         if (is_array($parsedBody) && isset($parsedBody[self::PARAM])) {
             $requestToSimulate = $parsedBody[self::PARAM];
             $deserializedRequest = RequestSerializer::fromString($requestToSimulate);
             $request = new ServerRequest($request->getServerParams(), $request->getUploadedFiles(), $deserializedRequest->getUri(), $deserializedRequest->getMethod(), $deserializedRequest->getBody(), $deserializedRequest->getHeaders());
         }
     }
     $requestAsString = RequestSerializer::toString($request);
     $responseResult = $next($request, $response);
     $responseAsString = ResponseSerializer::toString($responseResult);
     $html = sprintf($this->getHtmlTemplate(), self::PARAM, $requestAsString, $responseAsString);
     return new HtmlResponse($html);
 }
All Usage Examples Of Zend\Diactoros\Request\Serializer::fromString