HTTP Request/Response class I would like to get feedback on this, which are just simple Response/Request classes.

I tried to keep it simple, so I made two interfaces and two classes:


RequestInterface.php
Request.php
ResponseInterface.php
Response.php


The use Foo\Storage\ArrayHandler as access; is just a class to access and set arrays, so I wouldn't have to use functions like array_key_exists all over the place to check for keys, set, and unset arrays. 

RequestInterface.php

namespace Foo\Http;
interface RequestInterface
{
    public function get($key, $default = null);
    public function post($key, $default = null);
    public function server($key, $default = null);
    public function getMethod();
}


ResponseInterface.php

namespace Foo\Http; 
interface ResponseInterface
{
    public function setStatusCode($statusCode);
    public function addHeader($name, $value);
    public function setContentType($contentType);
    public function redirect($url);
}


Request.php

namespace Foo\Http;
use Foo\Storage\ArrayHandler as access; 
class Request implements RequestInterface
{

    protected $get; 
    protected $post;
    protected $files;
    protected $server;
    protected $cookies;


  public function __construct(
         access $get,
         access $post,
         access $files,
         access $server,
         access $cookies
    ) {
        $this-&gt;get = $get;
        $this-&gt;post = $post;
        $this-&gt;files = $files;
        $this-&gt;server = $server;
        $this-&gt;cookies = $cookies;
    }


    public function get($key, $defaultValue = null){
      return $this-&gt;get-&gt;get($key, $defaultValue);
    }

    public function post($key, $defaultValue = null){
        return $this-&gt;post-&gt;get($key, $defaultValue);
    }

    public function server($key, $defaultValue = null){
        return $this-&gt;server-&gt;get($key, $defaultValue); 
    }

    public function getMethod(){
        return $this-&gt;server-&gt;get('REQUEST_METHOD');
    }
}


Response.php

namespace Foo\Http; 

class Response implements ResponseInterface
{

    private $statusCode = 'HTTP/1.1 200 OK';
    private $headers = [];

    public function addHeader($name, $value){
        $this-&gt;headers[$name][] = $value;
    }

    public function setHeader($name, $value){
        $this-&gt;headers[$name] = [
            (string) $value,
        ];
    }

    public function redirect($url){
        $this-&gt;setHeader('Location', $url);
    }

}
You should take a look at Symfony's HttpFoundation component.

They've written various Request/Response objects similar to what you're attempting to do and they are extremely well done. Either I'd use them directly(save your own time). Or if this is an exploratory exercise then take a look at their code base to see how you can improve on your own solution.

It's not as sexy as writing your own objects, but it'll save you a lot of time and effort in the long run.