2db47680
hexiaodong
chore: 初始提交 php 遗...
|
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
|
<?php
namespace WeWork\Http;
class Response extends \GuzzleHttp\Psr7\Response
{
/**
* @inheritdoc
*/
public function getBody()
{
$stream = parent::getBody();
$data = json_decode((string)$stream, true);
if (JSON_ERROR_NONE === json_last_error() && $data['errcode'] !== 0) {
throw new \InvalidArgumentException($data['errmsg'], $data['errcode']);
}
return $stream;
}
/**
* @return array
*/
public function toArray(): array
{
return \GuzzleHttp\json_decode((string)$this->getBody(), true);
}
}
|