Вход Регистрация
Файл: vendor/intervention/image/src/Drivers/Gd/Decoders/DataUriImageDecoder.php
Строк: 52
<?php

declare(strict_types=1);

namespace 
InterventionImageDriversGdDecoders;

use 
InterventionImageExceptionsDecoderException;
use 
InterventionImageInterfacesColorInterface;
use 
InterventionImageInterfacesDecoderInterface;
use 
InterventionImageInterfacesImageInterface;

class 
DataUriImageDecoder extends BinaryImageDecoder implements DecoderInterface
{
    
/**
     * {@inheritdoc}
     *
     * @see DecoderInterface::decode()
     */
    
public function decode(mixed $input): ImageInterface|ColorInterface
    
{
        if (!
is_string($input)) {
            throw new 
DecoderException('Unable to decode input');
        }

        
$uri $this->parseDataUri($input);

        if (!
$uri->isValid()) {
            throw new 
DecoderException('Unable to decode input');
        }

        if (
$uri->isBase64Encoded()) {
            return 
parent::decode(base64_decode($uri->data()));
        }

        return 
parent::decode(urldecode($uri->data()));
    }
}
Онлайн: 2
Реклама