for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace TechDeCo\ElasticApmAgent\Message;
use JsonSerializable;
use Psr\Http\Message\ResponseInterface;
use TechDeCo\ElasticApmAgent\Serialization;
final class Response implements JsonSerializable
{
/**
* @var bool|null
*/
private $finished;
* @var mixed[]
private $headerList = [];
private $hasHeadersSent;
* @var int|null
private $httpStatusCode;
public static function fromHttpResponse(ResponseInterface $response): self
return (new self())->resultingInStatusCode($response->getStatusCode());
}
public function thatIsFinished(): self
$me = clone $this;
$me->finished = true;
return $me;
public function thatIsNotFinished(): self
$me->finished = false;
* @param mixed $value
public function withHeader(string $name, $value): self
$me->headerList[$name] = $value;
public function thatHasSentHeaders(): self
$me->hasHeadersSent = true;
public function thatHasNotSentHeaders(): self
$me->hasHeadersSent = false;
public function resultingInStatusCode(int $httpStatusCode): self
$me->httpStatusCode = $httpStatusCode;
* @return mixed[]
public function jsonSerialize(): array
return Serialization::filterUnset([
'finished' => $this->finished,
'headers' => $this->headerList,
'headers_sent' => $this->hasHeadersSent,
'status_code' => $this->httpStatusCode,
]);