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

declare(strict_types=1);

namespace 
InterventionImageDriversImagickDecoders;

use 
InterventionImageExceptionsDecoderException;
use 
InterventionImageExceptionsDirectoryNotFoundException;
use 
InterventionImageExceptionsDriverException;
use 
InterventionImageExceptionsFileNotFoundException;
use 
InterventionImageExceptionsFileNotReadableException;
use 
InterventionImageExceptionsImageDecoderException;
use 
InterventionImageExceptionsInvalidArgumentException;
use 
InterventionImageExceptionsStateException;
use 
SplFileInfo;
use 
InterventionImageInterfacesImageInterface;
use 
InterventionImageTraitsCanParseFilePath;

class 
SplFileInfoImageDecoder extends FilePathImageDecoder
{
    use 
CanParseFilePath;

    
/**
     * {@inheritdoc}
     *
     * @see DecoderInterface::supports()
     */
    
public function supports(mixed $input): bool
    
{
        return 
$input instanceof SplFileInfo;
    }

    
/**
     * {@inheritdoc}
     *
     * @see DecoderInterface::decode()
     *
     * @throws InvalidArgumentException
     * @throws DirectoryNotFoundException
     * @throws FileNotFoundException
     * @throws FileNotReadableException
     * @throws ImageDecoderException
     * @throws DriverException
     * @throws StateException
     */
    
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');
        }
    }
}
Онлайн: 2
Реклама