@@ -158,13 +158,12 @@ public function getFileType(): FileTypeEnum
158
158
*
159
159
* @since n.e.x.t
160
160
*
161
- * @return string The URL.
162
- * @throws \RuntimeException If the file is not remote.
161
+ * @return string|null The URL, or null if not a remote file.
163
162
*/
164
- public function getUrl (): string
163
+ public function getUrl (): ? string
165
164
{
166
165
if (!$ this ->fileType ->isRemote ()) {
167
- throw new \ RuntimeException ( ' Cannot get URL for non-remote file. ' ) ;
166
+ return null ;
168
167
}
169
168
170
169
return $ this ->data ;
@@ -175,30 +174,28 @@ public function getUrl(): string
175
174
*
176
175
* @since n.e.x.t
177
176
*
178
- * @return string The plain base64-encoded data (without data URI prefix).
179
- * @throws \RuntimeException If the file is not inline.
177
+ * @return string|null The plain base64-encoded data (without data URI prefix), or null if not an inline file.
180
178
*/
181
- public function getBase64Data (): string
179
+ public function getBase64Data (): ? string
182
180
{
183
181
if (!$ this ->fileType ->isInline ()) {
184
- throw new \ RuntimeException ( ' Cannot get base64 data for non-inline file. ' ) ;
182
+ return null ;
185
183
}
186
184
187
185
return $ this ->data ;
188
186
}
189
187
190
188
/**
191
- * Gets the data as a data URL for inline files.
189
+ * Gets the data as a data URI for inline files.
192
190
*
193
191
* @since n.e.x.t
194
192
*
195
- * @return string The data URL in format: data:[mimeType];base64,[data].
196
- * @throws \RuntimeException If the file is not inline.
193
+ * @return string|null The data URI in format: data:[mimeType];base64,[data], or null if not an inline file.
197
194
*/
198
- public function getDataUrl (): string
195
+ public function getDataUri (): ? string
199
196
{
200
197
if (!$ this ->fileType ->isInline ()) {
201
- throw new \ RuntimeException ( ' Cannot get data URL for non-inline file. ' ) ;
198
+ return null ;
202
199
}
203
200
204
201
return sprintf ('data:%s;base64,%s ' , $ this ->getMimeType (), $ this ->data );
0 commit comments