Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter #14

Closed
sagikazarmark opened this issue Dec 23, 2015 · 1 comment
Closed

Formatter #14

sagikazarmark opened this issue Dec 23, 2015 · 1 comment
Milestone

Comments

@sagikazarmark
Copy link
Member

We should be able to format Requests/Responses to string.

Basic interface

<?php

namespace Http\Message;

use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
 * Formats a request or a response into string.
 *
 * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
 */
interface Formatter
{
    /**
     * Formats a request.
     *
     * @param RequestInterface $request
     *
     * @return string
     */
    public function formatRequest(RequestInterface $request);

    /**
     * Formats a response.
     *
     * @param ResponseInterface $response
     *
     * @return string
     */
    public function formatResponse(ResponseInterface $response);
}

Some questions

  • Should we separate Request/Response format method into separate interfaces? (Like in case of message factories)

Default implementations

@sagikazarmark sagikazarmark modified the milestone: v0.2 Dec 23, 2015
@dbu
Copy link
Contributor

dbu commented Dec 24, 2015

+1
not sure about separating. a guzzle formatter makes absolutely no sense for a response. but it could just reuse the simple text formatter for the response and do its cool stuff on requests. that way, things are much simpler than having two interfaces that 90% of the time are provided by the same formatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants