Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
12 / 12
CRAP
100.00% covered (success)
100.00%
24 / 24
HTTP
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
12 / 12
14
100.00% covered (success)
100.00%
24 / 24
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 sapiServerRequest
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 request
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 output
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 outputResponseMessage
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 context
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 serverRequestContext
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
6 / 6
 contextContainer
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 messages
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 responses
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 builder
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 buildBuilder
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
namespace PHPixie;
class HTTP
{
    protected $builder;
    
    public function __construct($slice)
    {
        $this->builder = $this->buildBuilder($slice);
    }
    
    public function sapiServerRequest()
    {
        return $this->builder->messages()->sapiServerRequest();
    }
    
    public function request($serverRequest = null)
    {
        if($serverRequest === null) {
            $serverRequest = $this->sapiServerRequest();
        }
        return $this->builder->request($serverRequest);
    }
    
    public function output($response, $context = null)
    {
        $this->builder->output()->response($response, $context);
    }
    
    public function outputResponseMessage($responseMessage)
    {
        $this->builder->output()->responseMessage($responseMessage);
    }
    
    public function context($request, $session = null)
    {
        $serverRequest = $request->serverRequest();
        return $this->serverRequestContext($serverRequest, $session);
    }
    
    public function serverRequestContext($serverRequest, $session = null)
    {
        $cookieArray = $serverRequest->getCookieParams();
        $cookies = $this->builder->cookies($cookieArray);
        if($session === null) {
            $session = $this->builder->sapiSession();
        }
        
        return $this->builder->context($serverRequest, $cookies, $session);
    }
    
    public function contextContainer($context)
    {
        return $this->builder->contextContainer($context);
    }
    
    public function messages()
    {
        return $this->builder->messages();
    }
    
    public function responses()
    {
        return $this->builder->responses();
    }
 
    public function builder()
    {
        return $this->builder;
    }
    
    protected function buildBuilder($slice)
    {
        return new HTTP\Builder($slice);
    }
}