PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / ai / http-request / domain / response.php

response.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.5, at src/ai/http-request/domain/response.php

128 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4
5 namespace Yoast\WP\SEO\AI\HTTP_Request\Domain;
6
7 /**
8 * Class Response
9 * Represents a response from the AI Generator API.
10 */
11 class Response {
12
13 /**
14 * The response body.
15 *
16 * @var string
17 */
18 private $body;
19
20 /**
21 * The response code.
22 *
23 * @var int
24 */
25 private $response_code;
26
27 /**
28 * The response message.
29 *
30 * @var string
31 */
32 private $message;
33
34 /**
35 * The error code.
36 *
37 * @var string
38 */
39 private $error_code;
40
41 /**
42 * The missing licenses.
43 *
44 * @var array<string>
45 */
46 private $missing_licenses;
47
48 /**
49 * The response headers, keyed by lower-cased header name.
50 *
51 * @var array<string, string|array<string>>
52 */
53 private $headers;
54
55 /**
56 * Response constructor.
57 *
58 * @param string $body The response body.
59 * @param int $response_code The response code.
60 * @param string $message The response message.
61 * @param string $error_code The error code.
62 * @param array<string> $missing_licenses The missing licenses.
63 * @param array<string, string|array<string>> $headers The response headers, keyed by lower-cased header name.
64 */
65 public function __construct( string $body, int $response_code, string $message, string $error_code = '', $missing_licenses = [], array $headers = [] ) {
66 $this->body = $body;
67 $this->response_code = $response_code;
68 $this->message = $message;
69 $this->error_code = $error_code;
70 $this->missing_licenses = $missing_licenses;
71 $this->headers = $headers;
72 }
73
74 /**
75 * Gets the response body.
76 *
77 * @return string The response body.
78 */
79 public function get_body() {
80 return $this->body;
81 }
82
83 /**
84 * Gets the response code.
85 *
86 * @return int The response code.
87 */
88 public function get_response_code(): int {
89 return $this->response_code;
90 }
91
92 /**
93 * Gets the response message.
94 *
95 * @return string The response message.
96 */
97 public function get_message(): string {
98 return $this->message;
99 }
100
101 /**
102 * Gets the error code.
103 *
104 * @return string The error code.
105 */
106 public function get_error_code(): string {
107 return $this->error_code;
108 }
109
110 /**
111 * Gets the missing licenses.
112 *
113 * @return array<string> The missing licenses.
114 */
115 public function get_missing_licenses(): array {
116 return $this->missing_licenses;
117 }
118
119 /**
120 * Gets the response headers, keyed by lower-cased header name.
121 *
122 * @return array<string, string|array<string>> The response headers.
123 */
124 public function get_headers(): array {
125 return $this->headers;
126 }
127 }
128