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

declare(strict_types=1);

namespace 
InterventionGifDecoders;

use 
InterventionGifExceptionsDecoderException;
use 
InterventionGifBlocksHeader;

class 
HeaderDecoder extends AbstractDecoder
{
    
/**
     * Decode current sourc
     *
     * @throws DecoderException
     * @return Header
     */
    
public function decode(): Header
    
{
        
$header = new Header();
        
$header->setVersion($this->decodeVersion());

        return 
$header;
    }

    
/**
     * Decode version string
     *
     * @throws DecoderException
     * @return string
     */
    
protected function decodeVersion(): string
    
{
        
$parsed = (bool) preg_match("/^GIF(?P<version>[0-9]{2}[a-z])$/"$this->getNextBytes(6), $matches);

        if (
$parsed === false) {
            throw new 
DecoderException('Unable to parse file header.');
        }

        return 
$matches['version'];
    }
}
Онлайн: 0
Реклама