Files
soko-web/src/Response/Redirect.php
T
bence 4fe463fcc5
soko-web/pipeline/pr-master This commit looks good
do not use app container in classes
2023-04-19 23:26:24 +02:00

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;
}
}
}