PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
convertkit / vendor / wordpress / php-mcp-schema / src / Common / Content / DTO / AudioContent.php

AudioContent.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at vendor/wordpress/php-mcp-schema/src/Common/Content/DTO/AudioContent.php

188 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Common\Content\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Protocol\DTO\Annotations;
9 use WP\McpSchema\Common\Protocol\Union\ContentBlockInterface;
10 use WP\McpSchema\Common\Protocol\Union\SamplingMessageContentBlockInterface;
11 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
12
13 /**
14 * Audio provided to or from an LLM.
15 *
16 * @since 2025-03-26
17 * @last-updated 2025-11-25 (modified property: annotations)
18 *
19 * @mcp-domain Common
20 * @mcp-subdomain Content
21 * @mcp-version 2025-11-25
22 */
23 class AudioContent extends AbstractDataTransferObject implements SamplingMessageContentBlockInterface, ContentBlockInterface
24 {
25 use ValidatesRequiredFields;
26
27 public const TYPE = 'audio';
28
29 public const DISCRIMINATOR_FIELD = 'type';
30 public const DISCRIMINATOR_VALUE = 'audio';
31
32 /**
33 * @since 2025-03-26
34 *
35 * @var 'audio'
36 */
37 protected string $type;
38
39 /**
40 * The base64-encoded audio data.
41 *
42 * @since 2025-03-26
43 *
44 * @var string
45 */
46 protected string $data;
47
48 /**
49 * The MIME type of the audio. Different providers may support different audio types.
50 *
51 * @since 2025-03-26
52 *
53 * @var string
54 */
55 protected string $mimeType;
56
57 /**
58 * Optional annotations for the client.
59 *
60 * @since 2025-03-26
61 *
62 * @var \WP\McpSchema\Common\Protocol\DTO\Annotations|null
63 */
64 protected ?Annotations $annotations;
65
66 /**
67 * See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.
68 *
69 * @since 2025-06-18
70 *
71 * @var array<string, mixed>|null
72 */
73 protected ?array $_meta;
74
75 /**
76 * @param string $data @since 2025-03-26
77 * @param string $mimeType @since 2025-03-26
78 * @param \WP\McpSchema\Common\Protocol\DTO\Annotations|null $annotations @since 2025-03-26
79 * @param array<string, mixed>|null $_meta @since 2025-06-18
80 */
81 public function __construct(
82 string $data,
83 string $mimeType,
84 ?Annotations $annotations = null,
85 ?array $_meta = null
86 ) {
87 $this->type = self::TYPE;
88 $this->data = $data;
89 $this->mimeType = $mimeType;
90 $this->annotations = $annotations;
91 $this->_meta = $_meta;
92 }
93
94 /**
95 * Creates an instance from an array.
96 *
97 * @param array{
98 * type: 'audio',
99 * data: string,
100 * mimeType: string,
101 * annotations?: array<string, mixed>|\WP\McpSchema\Common\Protocol\DTO\Annotations|null,
102 * _meta?: array<string, mixed>|null
103 * } $data
104 * @phpstan-param array<string, mixed> $data
105 * @return self
106 */
107 public static function fromArray(array $data): self
108 {
109 self::assertRequired($data, ['data', 'mimeType']);
110
111 /** @var \WP\McpSchema\Common\Protocol\DTO\Annotations|null $annotations */
112 $annotations = isset($data['annotations'])
113 ? (is_array($data['annotations'])
114 ? Annotations::fromArray(self::asArray($data['annotations']))
115 : $data['annotations'])
116 : null;
117
118 return new self(
119 self::asString($data['data']),
120 self::asString($data['mimeType']),
121 $annotations,
122 self::asArrayOrNull($data['_meta'] ?? null)
123 );
124 }
125
126 /**
127 * Converts the instance to an array.
128 *
129 * @return array<string, mixed>
130 */
131 public function toArray(): array
132 {
133 $result = [];
134
135 $result['type'] = $this->type;
136 $result['data'] = $this->data;
137 $result['mimeType'] = $this->mimeType;
138 if ($this->annotations !== null) {
139 $result['annotations'] = $this->annotations->toArray();
140 }
141 if ($this->_meta !== null) {
142 $result['_meta'] = $this->_meta;
143 }
144
145 return $result;
146 }
147
148 /**
149 * @return 'audio'
150 */
151 public function getType(): string
152 {
153 return $this->type;
154 }
155
156 /**
157 * @return string
158 */
159 public function getData(): string
160 {
161 return $this->data;
162 }
163
164 /**
165 * @return string
166 */
167 public function getMimeType(): string
168 {
169 return $this->mimeType;
170 }
171
172 /**
173 * @return \WP\McpSchema\Common\Protocol\DTO\Annotations|null
174 */
175 public function getAnnotations(): ?Annotations
176 {
177 return $this->annotations;
178 }
179
180 /**
181 * @return array<string, mixed>|null
182 */
183 public function get_meta(): ?array
184 {
185 return $this->_meta;
186 }
187 }
188