You've already forked Php-Template
refactor: remove status_code from response classes and update related tests
Some checks failed
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m5s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Failing after 2m56s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 3m12s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 3m32s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m17s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m42s
Some checks failed
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m5s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Failing after 2m56s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 3m12s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 3m32s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m17s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m42s
This commit is contained in:
@@ -11,14 +11,12 @@ use OpenApi\Attributes as OA;
|
||||
schema: 'GenericResponse',
|
||||
properties: [
|
||||
new OA\Property(property: 'message', type: 'string', example: 'Operation completed successfully.'),
|
||||
new OA\Property(property: 'status_code', type: 'integer', example: 200),
|
||||
]
|
||||
)]
|
||||
readonly class GenericResponse implements Arrayable
|
||||
{
|
||||
public function __construct(
|
||||
private string $message = '',
|
||||
private int $statusCode = 200
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -26,7 +24,6 @@ readonly class GenericResponse implements Arrayable
|
||||
{
|
||||
return [
|
||||
'message' => $this->message,
|
||||
'status_code' => $this->statusCode,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ use OpenApi\Attributes as OA;
|
||||
type: 'string',
|
||||
example: 'The requested resource /api/resource was not found.'
|
||||
),
|
||||
new OA\Property(property: 'status_code', type: 'integer', example: 404),
|
||||
new OA\Property(
|
||||
property: 'context',
|
||||
description: 'Additional context about the not found error.',
|
||||
@@ -32,7 +31,6 @@ readonly class NotFoundResponse implements Arrayable
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'status_code' => CodesEnum::NOT_FOUND->value,
|
||||
'message' => 'The requested resource ' . $this->uri . ' was not found.',
|
||||
'context' => $this->context,
|
||||
];
|
||||
|
||||
@@ -11,7 +11,7 @@ use OpenApi\Attributes as OA;
|
||||
schema: 'ServerErrorResponse',
|
||||
properties: array(
|
||||
new OA\Property(property: 'message', type: 'string', example: 'An internal server error occurred.'),
|
||||
new OA\Property(property: 'status_code', type: 'integer', example: 500),
|
||||
new OA\Property(property: 'code', type: 'integer', example: 500),
|
||||
new OA\Property(
|
||||
property: 'file',
|
||||
type: 'string',
|
||||
@@ -35,7 +35,7 @@ readonly class ServerErrorResponse implements Arrayable
|
||||
{
|
||||
if (Config::get('app.dev_mode')) {
|
||||
return [
|
||||
'status_code' => $this->e->getCode() != 0 ?
|
||||
'code' => $this->e->getCode() != 0 ?
|
||||
$this->e->getCode() :
|
||||
CodesEnum::INTERNAL_SERVER_ERROR->value,
|
||||
'message' => $this->e->getMessage(),
|
||||
@@ -47,7 +47,7 @@ readonly class ServerErrorResponse implements Arrayable
|
||||
}
|
||||
|
||||
return [
|
||||
'status_code' => $this->e->getCode() != 0 ?
|
||||
'code' => $this->e->getCode() != 0 ?
|
||||
$this->e->getCode() :
|
||||
CodesEnum::INTERNAL_SERVER_ERROR->value,
|
||||
'message' => 'An internal server error occurred.',
|
||||
|
||||
Reference in New Issue
Block a user