PluginProbe
Auto Alt Text / trunk
Auto Alt Text vtrunk
3.0.3 2.8.2 1.3.1 1.3.2 2.0.0 2.1.0 2.1.1 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.7.0 2.8.0 2.8.1 All 28 releases
auto-alt-text / src / App / Domain / Exceptions / InvalidImageException.php

InvalidImageException.php in Auto Alt Text trunk, at src/App/Domain/Exceptions/InvalidImageException.php

38 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AATXT\App\Domain\Exceptions;
4
5 use Exception;
6
7 /**
8 * Exception thrown when an image is invalid or has unsupported MIME type.
9 *
10 * This exception is thrown when attempting to generate alt text for an image
11 * that doesn't meet the provider's requirements (e.g., unsupported format).
12 */
13 class InvalidImageException extends Exception
14 {
15 /**
16 * Constructor
17 *
18 * @param int $imageId The WordPress attachment ID
19 * @param string $mimeType The MIME type of the image
20 * @param array $supportedTypes List of supported MIME types
21 */
22 public function __construct(int $imageId, string $mimeType, array $supportedTypes = [])
23 {
24 $supportedList = !empty($supportedTypes)
25 ? implode(', ', $supportedTypes)
26 : 'none specified';
27
28 parent::__construct(
29 sprintf(
30 'Image ID %d has unsupported MIME type "%s". Supported types: %s',
31 $imageId,
32 $mimeType,
33 $supportedList
34 )
35 );
36 }
37 }
38