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

declare(strict_types=1);

namespace 
InterventionGifTraits;

use 
InterventionGifDecodersAbstractDecoder;
use 
InterventionGifExceptionsDecoderException;

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

    
/**
     * Get decoder for current instance
     *
     * @param resource $source
     * @param null|int $length
     * @throws DecoderException
     * @return AbstractDecoder
     */
    
protected static function getDecoder($source, ?int $length null): AbstractDecoder
    
{
        
$classname self::getDecoderClassname();

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

        return new 
$classname($source$length);
    }

    
/**
     * Get classname of decoder for current classname
     *
     * @return string
     */
    
protected static function getDecoderClassname(): string
    
{
        return 
sprintf('InterventionGifDecoders%sDecoder'self::getShortClassname());
    }
}
Онлайн: 0
Реклама