for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Rogierw\RwAcme\Http;
use Rogierw\RwAcme\Support\Str;
class Response
{
private $rawHeaders;
private $headers;
private $body;
private $error;
public function __construct($rawHeaders, $headers, $body, $error)
$this->rawHeaders = $rawHeaders;
$this->headers = $headers;
$this->body = $body;
$this->error = $error;
}
/** @return mixed */
public function getRawHeaders()
$headers = explode("\n", $this->rawHeaders);
$headersArr = [];
foreach ($headers as $header) {
if (!Str::contains($header, ':')) {
continue;
[$name, $value] = explode(':', $header, 2);
$headersArr[$name] = $value;
return $headersArr;
public function getHeaders()
return $this->headers;
public function getBody()
return $this->body;
/** @return bool */
public function hasBody()
return $this->body != false;
public function getError()
return $this->error;
/** @return null|int */
public function getHttpResponseCode()
if (!isset($this->headers['http_code'])) {
return;
return (int) $this->headers['http_code'];