-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d29486
commit 74da0b5
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<? | ||
declare(strict_types=1); | ||
|
||
namespace Pion\Http\Response\Redirect; | ||
|
||
use Pion\Http\Response\Headers\Headers; | ||
use Pion\Http\Response\Headers\HeadersInterface; | ||
use Pion\Http\Response\Redirect\Headers\LocationHeader; | ||
use Pion\Http\Response\ResponseInterface; | ||
use Pion\Http\Response\Status\PredefinedStatus; | ||
use Pion\Http\Response\Status\StatusInterface; | ||
use Pion\Http\Response\Stream\Stream; | ||
use Pion\Http\Response\Stream\StreamInterface; | ||
use Psr\Http\Message\UriInterface; | ||
|
||
class UriRedirectResponse implements ResponseInterface | ||
{ | ||
/** | ||
* @var UriInterface | ||
*/ | ||
private $uri; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $statusCode; | ||
|
||
public function __construct(UriInterface $uri, int $status = null) { | ||
$this->uri = $uri; | ||
$this->statusCode = $status ?? 302; | ||
} | ||
|
||
public function status(): StatusInterface | ||
{ | ||
return new PredefinedStatus($this->statusCode, ''); | ||
} | ||
|
||
public function headers(): HeadersInterface | ||
{ | ||
return new Headers(new LocationHeader($this->uri)); | ||
} | ||
|
||
public function stream(): StreamInterface | ||
{ | ||
return new Stream(''); | ||
} | ||
} |