This commit is contained in:
2021-08-27 16:49:17 +08:00
parent 5f199ccb19
commit 98b7048db7
6 changed files with 955 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace Server\Message;
use Psr\Http\Message\ResponseInterface;
/**
*
*/
class Response implements ResponseInterface
{
use Message;
public int $statusCode = 200;
public string $reasonPhrase = '';
/**
* @return int
*/
public function getStatusCode(): int
{
// TODO: Implement getStatusCode() method.
return $this->statusCode;
}
/**
* @param int $code
* @param string $reasonPhrase
* @return ResponseInterface
*/
public function withStatus($code, $reasonPhrase = ''): ResponseInterface
{
// TODO: Implement withStatus() method.
$class = clone $this;
$class->statusCode = $code;
$class->reasonPhrase = $reasonPhrase;
return $class;
}
/**
* @return string
*/
public function getReasonPhrase(): string
{
// TODO: Implement getReasonPhrase() method.
return $this->reasonPhrase;
}
}