Файл: vendor/intervention/gif/src/Encoders/ImageDataEncoder.php
Строк: 62
<?php
declare(strict_types=1);
namespace InterventionGifEncoders;
use InterventionGifAbstractEntity;
use InterventionGifBlocksDataSubBlock;
use InterventionGifBlocksImageData;
use InterventionGifExceptionsEncoderException;
use InterventionGifExceptionsStateException;
class ImageDataEncoder extends AbstractEncoder
{
/**
* Create new instance.
*/
public function __construct(ImageData $entity)
{
parent::__construct($entity);
}
/**
* Encode current entity.
*
* @throws EncoderException
* @throws StateException
*/
public function encode(): string
{
if (!$this->entity->hasBlocks()) {
throw new StateException('No data blocks in image data');
}
return implode('', [
pack('C', $this->entity->lzwMinCodeSize()),
implode('', array_map(
fn(DataSubBlock $block): string => $block->encode(),
$this->entity->blocks(),
)),
AbstractEntity::TERMINATOR,
]);
}
}