36 lines
689 B
PHP
36 lines
689 B
PHP
<?php namespace SokoWeb\Response;
|
|
|
|
use SokoWeb\Interfaces\Response\IRedirect;
|
|
|
|
class Redirect implements IRedirect
|
|
{
|
|
private string $target;
|
|
|
|
private int $type;
|
|
|
|
public function __construct(string $target, int $type = IRedirect::TEMPORARY)
|
|
{
|
|
$this->target = $target;
|
|
$this->type = $type;
|
|
}
|
|
|
|
public function getTarget(): string
|
|
{
|
|
return $this->target;
|
|
}
|
|
|
|
public function getHttpCode(): int
|
|
{
|
|
switch ($this->type) {
|
|
case IRedirect::PERMANENT:
|
|
return 301;
|
|
|
|
case IRedirect::TEMPORARY:
|
|
return 302;
|
|
|
|
default:
|
|
return 302;
|
|
}
|
|
}
|
|
}
|