first commit.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
/**
|
||||
* Respuesta capturada de una petición despachada in-process.
|
||||
*/
|
||||
class Response
|
||||
{
|
||||
public function __construct(
|
||||
public int $status,
|
||||
public string $body,
|
||||
public array $headers = [],
|
||||
public array $cookies = [],
|
||||
) {
|
||||
}
|
||||
|
||||
public function header(string $name): ?string
|
||||
{
|
||||
foreach ($this->headers as $header) {
|
||||
if (stripos($header, $name . ':') === 0) {
|
||||
return trim(substr($header, strlen($name) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function hasHeader(string $name): bool
|
||||
{
|
||||
return $this->header($name) !== null;
|
||||
}
|
||||
|
||||
public function redirectTarget(): ?string
|
||||
{
|
||||
return $this->header('HX-Redirect') ?? $this->header('Location');
|
||||
}
|
||||
|
||||
public function trigger(): ?string
|
||||
{
|
||||
return $this->header('HX-Trigger');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user