Вход Регистрация
Файл: vendor/intervention/gif/src/Traits/CanDecode.php
Строк: 55
<?php

declare(strict_types=1);

namespace 
InterventionGifTraits;

use 
InterventionGifDecodersAbstractDecoder;
use 
InterventionGifExceptionsDecoderException;

trait 
CanDecode
{
    
/**
     * Decode current instance.
     *
     * @throws DecoderException
     */
    
public static function decode(mixed $source, ?int $length null): mixed
    
{
        return 
self::decoder($source$length)->decode();
    }

    
/**
     * Get decoder for current instance.
     *
     * @throws DecoderException
     */
    
protected static function decoder(mixed $source, ?int $length null): AbstractDecoder
    
{
        
$classname sprintf('InterventionGifDecoders%sDecoder'self::shortClassname());

        if (!
class_exists($classname)) {
            throw new 
DecoderException('Decoder for "' . static::class . '" not found');
        }

        
$decoder = new $classname($source$length);

        if (!(
$decoder instanceof AbstractDecoder)) {
            throw new 
DecoderException('Decoder for "' . static::class . '" not found');
        }

        return 
$decoder;
    }
}
Онлайн: 1
Реклама