Response.php
712 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace AukeySwrpc;
/**
* Class Response
*
* @package Swrpc
* @author pengjch 202439 11:36:9
*/
class Response
{
const RES_ERROR = 0;
const RES_SUCCESS = 1;
public string $msg;
public int $code;
public array $data;
public function __construct($code, $msg, $data)
{
$this->data = $data;
$this->code = $code;
$this->msg = $msg;
}
public static function error($msg, $code = self::RES_ERROR, $data = []): Response
{
return new static($code, $msg, $data);
}
public static function success($data = [], $msg = 'success', $code = self::RES_SUCCESS): Response
{
return new static($code, $msg, $data);
}
}