Total Complexity | 12 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class CurlResponse |
||
13 | { |
||
14 | |||
15 | private $http_code = 0; |
||
16 | private $result = ''; |
||
17 | |||
18 | public function __construct($http_code, $result) |
||
19 | { |
||
20 | $this->http_code = $http_code; |
||
21 | $this->result = $result; |
||
22 | } |
||
23 | |||
24 | public function isValid() |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return int |
||
31 | */ |
||
32 | public function getHTTPCode() |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return array|null |
||
39 | */ |
||
40 | public function getJSON(): ?array |
||
41 | { |
||
42 | $data = json_decode($this->result, true); |
||
43 | if (!is_array($data)) return null; |
||
44 | |||
45 | return $data; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return bool |
||
50 | */ |
||
51 | public function isJSON(): bool |
||
54 | } |
||
55 | |||
56 | public function getError() |
||
57 | { |
||
58 | return (count($this->getErrors())) ? $this->getErrors()[0]['error'] : $this->getRaw(); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return array |
||
63 | */ |
||
64 | public function getErrors(): array |
||
67 | } |
||
68 | |||
69 | public function getRaw() |
||
72 | } |
||
73 | } |