Add interfaces for requests and responses
This commit is contained in:
parent
b28b53aa11
commit
ac752bb446
|
|
@ -73,9 +73,9 @@ abstract class Handler implements HandlerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \pjdietz\WellRESTed\Request $request
|
||||
* @param RequestInterface $request
|
||||
*/
|
||||
public function setRequest($request)
|
||||
public function setRequest(RequestInterface $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ abstract class Handler implements HandlerInterface
|
|||
/**
|
||||
* Return the instance's Reponse
|
||||
*
|
||||
* @return Response
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
namespace pjdietz\WellRESTed;
|
||||
|
||||
/**
|
||||
* Interface for a creating a response in reaction to a respond or arguments.
|
||||
* @package pjdietz\WellRESTed
|
||||
*/
|
||||
interface HandlerInterface
|
||||
{
|
||||
public function getRequest();
|
||||
public function setRequest($request);
|
||||
public function setRequest(RequestInterface $request);
|
||||
public function getArguments();
|
||||
public function setArguments(array $args);
|
||||
public function getResponse();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace pjdietz\WellRESTed;
|
|||
* @property array query Associative array of query parameters
|
||||
* @property array uri Full URI (protocol, hostname, path, etc.)
|
||||
*/
|
||||
class Request extends Message
|
||||
class Request extends Message implements RequestInterface
|
||||
{
|
||||
/**
|
||||
* The Hostname for the request (e.g., www.google.com)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace pjdietz\WellRESTed;
|
||||
|
||||
/**
|
||||
* Interface for representing an HTTP request.
|
||||
* @package pjdietz\WellRESTed
|
||||
*/
|
||||
interface RequestInterface
|
||||
{
|
||||
public function getMethod();
|
||||
public function setMethod($method);
|
||||
public function getUri();
|
||||
public function setUri($uri);
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ use \InvalidArgumentException;
|
|||
* @property-read string statusLine HTTP status line, e.g. "HTTP/1.1 200 OK"
|
||||
* @property-read bool success True if the status code is 2xx
|
||||
*/
|
||||
class Response extends Message
|
||||
class Response extends Message implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Text explanation of the HTTP Status Code. You only need to set this if
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace pjdietz\WellRESTed;
|
||||
|
||||
/**
|
||||
* Interface for representing an HTTP response.
|
||||
* @package pjdietz\WellRESTed
|
||||
*/
|
||||
interface ResponseInterface
|
||||
{
|
||||
public function respond();
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ namespace pjdietz\WellRESTed;
|
|||
|
||||
/**
|
||||
* Interface for a route to relate a pattern for matching a URI to a handler class.
|
||||
* @package pjdietz\WellRESTed
|
||||
*/
|
||||
interface RouteInterface
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue