PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / apimatic / unirest-php / src / Response.php
ameliabooking / vendor / apimatic / unirest-php / src Last commit date
Request 1 year ago Configuration.php 1 year ago HttpClient.php 1 year ago Response.php 1 year ago
Response.php
67 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Unirest;
6
7 use CoreInterfaces\Core\Response\ResponseInterface;
8 use CoreInterfaces\Sdk\ConverterInterface;
9
10 class Response implements ResponseInterface
11 {
12 private $code;
13 private $raw_body;
14 private $body;
15 private $headers;
16
17 /**
18 * @param int $code response code of the cURL request
19 * @param string $raw_body the raw body of the cURL response
20 * @param array $headers parsed headers array from cURL response
21 * @param array $json_args arguments to pass to json_decode function
22 */
23 public function __construct(int $code, string $raw_body, array $headers, array $json_args = [])
24 {
25 $this->code = $code;
26 $this->headers = $headers;
27 $this->raw_body = $raw_body;
28 $this->body = $raw_body;
29
30 // make sure raw_body is the first argument
31 array_unshift($json_args, $raw_body);
32
33 if (function_exists('json_decode')) {
34 $json = call_user_func_array('json_decode', $json_args);
35
36 if (json_last_error() === JSON_ERROR_NONE) {
37 $this->body = $json;
38 }
39 }
40 }
41
42 public function getStatusCode(): int
43 {
44 return $this->code;
45 }
46
47 public function getHeaders(): array
48 {
49 return $this->headers;
50 }
51
52 public function getRawBody(): string
53 {
54 return $this->raw_body;
55 }
56
57 public function getBody()
58 {
59 return $this->body;
60 }
61
62 public function convert(ConverterInterface $converter)
63 {
64 return $converter->createHttpResponse($this);
65 }
66 }
67