Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
18 / 18 |
CRAP | |
100.00% |
30 / 30 |
Builder | |
100.00% |
1 / 1 |
|
100.00% |
18 / 18 |
19 | |
100.00% |
30 / 30 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
messages | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
responses | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
output | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
request | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
data | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
headers | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
editableHeaders | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
serverData | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
context | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
cookies | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
sapiSession | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
cookiesUpdate | |
100.00% |
1 / 1 |
1 | |
100.00% |
8 / 8 |
|||
contextContainer | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
instance | |
100.00% |
1 / 1 |
2 | |
100.00% |
5 / 5 |
|||
buildMessages | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
buildResponses | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
buildOutput | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
<?php | |
namespace PHPixie\HTTP; | |
class Builder | |
{ | |
protected $slice; | |
protected $instances = array(); | |
public function __construct($slice) { | |
$this->slice = $slice; | |
} | |
public function messages() | |
{ | |
return $this->instance('messages'); | |
} | |
public function responses() | |
{ | |
return $this->instance('responses'); | |
} | |
public function output() | |
{ | |
return $this->instance('output'); | |
} | |
public function request($serverRequest) | |
{ | |
return new Request($this, $serverRequest); | |
} | |
public function data($array = array()) | |
{ | |
return $this->slice->arrayData($array); | |
} | |
public function headers($headerArray = array()) | |
{ | |
return new Data\Headers($headerArray); | |
} | |
public function editableHeaders($headerArray = array()) | |
{ | |
return new Data\Headers\Editable($headerArray); | |
} | |
public function serverData($serverData = array()) | |
{ | |
return new Data\Server($serverData); | |
} | |
public function context($serverRequest, $cookies, $session) | |
{ | |
return new Context($serverRequest, $cookies, $session); | |
} | |
public function cookies($cookieArray = array()) | |
{ | |
return new Context\Cookies($this, $cookieArray); | |
} | |
public function sapiSession() | |
{ | |
return new Context\Session\SAPI(); | |
} | |
public function cookiesUpdate( | |
$name, | |
$value, | |
$expires = null, | |
$path = '/', | |
$domain = null, | |
$secure = false, | |
$httpOnly = false | |
) | |
{ | |
return new Context\Cookies\Update( | |
$name, | |
$value, | |
$expires, | |
$path, | |
$domain, | |
$secure, | |
$httpOnly | |
); | |
} | |
public function contextContainer($context) | |
{ | |
return new Context\Container\Implementation($context); | |
} | |
protected function instance($name) | |
{ | |
if(!array_key_exists($name, $this->instances)) { | |
$method = 'build'.ucfirst($name); | |
$this->instances[$name] = $this->$method(); | |
} | |
return $this->instances[$name]; | |
} | |
protected function buildMessages() | |
{ | |
return new Messages(); | |
} | |
protected function buildResponses() | |
{ | |
return new Responses($this); | |
} | |
protected function buildOutput() | |
{ | |
return new Output(); | |
} | |
} |