Файл: vendor/intervention/image/src/Drivers/Gd/Decoders/SplFileInfoImageDecoder.php
Строк: 116
<?php
declare(strict_types=1);
namespace InterventionImageDriversGdDecoders;
use SplFileInfo;
use InterventionImageExceptionsDecoderException;
use InterventionImageExceptionsDirectoryNotFoundException;
use InterventionImageExceptionsDriverException;
use InterventionImageExceptionsFileNotFoundException;
use InterventionImageExceptionsFileNotReadableException;
use InterventionImageExceptionsImageDecoderException;
use InterventionImageExceptionsInvalidArgumentException;
use InterventionImageExceptionsStateException;
use InterventionImageInterfacesDecoderInterface;
use InterventionImageInterfacesImageInterface;
use InterventionImageTraitsCanParseFilePath;
class SplFileInfoImageDecoder extends FilePathImageDecoder implements DecoderInterface
{
use CanParseFilePath;
/**
* {@inheritdoc}
*
* @see DecoderInterface::supports()
*/
public function supports(mixed $input): bool
{
return $input instanceof SplFileInfo;
}
/**
* {@inheritdoc}
*
* @see DecoderInterface::decode()
*
* @throws InvalidArgumentException
* @throws ImageDecoderException
* @throws DriverException
* @throws StateException
* @throws DirectoryNotFoundException
* @throws FileNotFoundException
* @throws FileNotReadableException
*/
public function decode(mixed $input): ImageInterface
{
if (!$input instanceof SplFileInfo) {
throw new InvalidArgumentException('Image source must be of type ' . SplFileInfo::class);
}
try {
return parent::decode(self::filePathFromSplFileInfoOrFail($input));
} catch (DecoderException) {
throw new ImageDecoderException(SplFileInfo::class . ' contains unsupported image type');
}
}
}