jakson-fischer/returns 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jakson-fischer/returns

最新稳定版本:v1.0.2

Composer 安装命令:

composer require jakson-fischer/returns

包简介

Classe para padronizar retornos em sistemas

README 文档

README

Português (pt-BR)

Descrição

Módulo criado para padronização de retornos de sistemas e APIs. O módulo pode ser utilizado para padronização dos retornos, quando necessário.

Instalação

Para instalar o módulo via Composer, execute o seguinte comando:

composer require jakson-fischer/returns

Parâmetros

  • $status: bool, obrigatório
  • $message: string, obrigatório
  • $errorCode: não obrigatório (Campo aberto para uso interno, a documentação ficará na responsabilidade do usuário)
  • $errorType: não obrigatório
  • $httpStatus: não obrigatório

Funções

  • toArray: Retorno dos dados enviados no formato de array.
  • toJson: Retorno dos dados enviados no formato JSON.
  • arrayDataReturn: Retorna os dados enviados encapsulados em um array dentro da chave data.
  • jsonDataReturn: Retorna os dados enviados encapsulados em JSON dentro da chave data.

Exemplos de uso

Chamada da classe

use JaksonFischer\Returns\Returns;

echo Returns::toJson(true, "Test success message", NULL, NULL, 200);

toArray

Entrada:

return Returns::toArray(false, "Cliente não está autenticado no sistema!", "#EA1527", "Erro de sistema", 511);

Saída:

[
    "status" => false, 
    "msg" => "Cliente não está autenticado no sistema!", 
    "errorCode" => "#EA1527", 
    "errorType" => "Erro de sistema", 
    "httpStatus" => 511 
]

toJson

Entrada:

return Returns::toJson(false, "Cliente não está autenticado no sistema!", "#EA1527", "Erro de sistema", 511);

Saída:

{
    "status": false,
    "msg": "Cliente não está autenticado no sistema!",
    "errorCode": "#EA1527",
    "errorType": "Erro de sistema",
    "httpStatus": 511
}

arrayDataReturn

Entrada:

Returns::arrayDataReturn(false, "Cliente não está autenticado no sistema!", "#EA1527", "Erro de sistema", 511);

Saída:

[
    "data" => [
        "status" => false,
        "msg" => "Cliente não está autenticado no sistema!",
        "errorCode" => "#EA1527",
        "errorType" => "Erro de sistema",
        "httpStatus" => 511
    ]
]

jsonDataReturn

Entrada:

Returns::jsonDataReturn(false, "Cliente não está autenticado no sistema!", "#EA1527", "Erro de sistema", 511);

Saída:

{
    "data": {
        "status": false,
        "msg": "Cliente não está autenticado no sistema!",
        "errorCode": "#EA1527",
        "errorType": "Erro de sistema",
        "httpStatus": 511
    }
}

Returns

English

Description

This module was created to standardize the returns for systems and APIs. It can be used for return standardization whenever necessary.

Installation

To install the module via Composer, run the following command:

composer require jakson-fischer/returns

Parameters

  • $status: bool, required
  • $message: string, required
  • $errorCode: optional (Open field for internal use, documentation responsibility lies with the user)
  • $errorType: optional
  • $httpStatus: optional

Functions

  • toArray: Returns the sent data as an array.
  • toJson: Returns the sent data as JSON.
  • arrayDataReturn: Returns the sent data encapsulated in an array under the data key.
  • jsonDataReturn: Returns the sent data encapsulated in JSON under the data key.

Usage examples

Call class

use JaksonFischer\Returns\Returns;

echo Returns::toJson(true, "Test success message", NULL, NULL, 200);

toArray

Input:

return Returns::toArray(false, "Client is not authenticated in the system!", "#EA1527", "System error", 511);

Output:

[
    "status" => false, 
    "msg" => "Client is not authenticated in the system!", 
    "errorCode" => "#EA1527", 
    "errorType" => "System error", 
    "httpStatus" => 511 
]

toJson

Input:

return Returns::toJson(false, "Client is not authenticated in the system!", "#EA1527", "System error", 511);

Output:

{
    "status": false,
    "msg": "Client is not authenticated in the system!",
    "errorCode": "#EA1527",
    "errorType": "System error",
    "httpStatus": 511
}

arrayDataReturn

Input:

Returns::arrayDataReturn(false, "Client is not authenticated in the system!", "#EA1527", "System error", 511);

Output:

[
    "data" => [
        "status" => false,
        "msg" => "Client is not authenticated in the system!",
        "errorCode" => "#EA1527",
        "errorType" => "System error",
        "httpStatus" => 511
    ]
]

jsonDataReturn

Input:

Returns::jsonDataReturn(false, "Client is not authenticated in the system!", "#EA1527", "System error", 511);

Output:

{
    "data": {
        "status": false,
        "msg": "Client is not authenticated in the system!",
        "errorCode": "#EA1527",
        "errorType": "System error",
        "httpStatus": 511
    }
}

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-30