Файл: vendor/intervention/image/src/Drivers/Gd/Decoders/Base64ImageDecoder.php
Строк: 62
<?php
declare(strict_types=1);
namespace InterventionImageDriversGdDecoders;
use InterventionImageExceptionsDecoderException;
use InterventionImageExceptionsImageDecoderException;
use InterventionImageInterfacesDecoderInterface;
use InterventionImageInterfacesImageInterface;
use InterventionImageTraitsCanDetectImageSources;
class Base64ImageDecoder extends BinaryImageDecoder implements DecoderInterface
{
use CanDetectImageSources;
/**
* {@inheritdoc}
*
* @see DecoderInterface::supports()
*/
public function supports(mixed $input): bool
{
return $this->couldBeBase64Data($input);
}
/**
* {@inheritdoc}
*
* @see DecoderInterface::decode()
*/
public function decode(mixed $input): ImageInterface
{
try {
$data = $this->decodeBase64Data($input);
} catch (DecoderException) {
throw new ImageDecoderException('Unable to Base64-decode image from string');
}
try {
return parent::decode($data);
} catch (DecoderException) {
throw new ImageDecoderException('Base64-encoded data contains unsupported image type');
}
}
}