refactor: susun semula struktur folder — Laravel source ke src/
This commit is contained in:
21
vendor/intervention/gif/src/Encoders/AbstractEncoder.php
vendored
Normal file
21
vendor/intervention/gif/src/Encoders/AbstractEncoder.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
abstract class AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
abstract public function encode(): string;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(protected mixed $entity)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
37
vendor/intervention/gif/src/Encoders/ApplicationExtensionEncoder.php
vendored
Normal file
37
vendor/intervention/gif/src/Encoders/ApplicationExtensionEncoder.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\ApplicationExtension;
|
||||
use Intervention\Gif\Blocks\DataSubBlock;
|
||||
use Intervention\Gif\Exceptions\EncoderException;
|
||||
|
||||
class ApplicationExtensionEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new decoder instance.
|
||||
*/
|
||||
public function __construct(ApplicationExtension $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
ApplicationExtension::MARKER,
|
||||
ApplicationExtension::LABEL,
|
||||
pack('C', $this->entity->blockSize()),
|
||||
$this->entity->application(),
|
||||
implode('', array_map(fn(DataSubBlock $block): string => $block->encode(), $this->entity->blocks())),
|
||||
ApplicationExtension::TERMINATOR,
|
||||
]);
|
||||
}
|
||||
}
|
||||
38
vendor/intervention/gif/src/Encoders/ColorEncoder.php
vendored
Normal file
38
vendor/intervention/gif/src/Encoders/ColorEncoder.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\Color;
|
||||
|
||||
class ColorEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(Color $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
$this->encodeColorValue($this->entity->red()),
|
||||
$this->encodeColorValue($this->entity->green()),
|
||||
$this->encodeColorValue($this->entity->blue()),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode color value.
|
||||
*/
|
||||
private function encodeColorValue(int $value): string
|
||||
{
|
||||
return pack('C', $value);
|
||||
}
|
||||
}
|
||||
33
vendor/intervention/gif/src/Encoders/ColorTableEncoder.php
vendored
Normal file
33
vendor/intervention/gif/src/Encoders/ColorTableEncoder.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\Color;
|
||||
use Intervention\Gif\Blocks\ColorTable;
|
||||
use Intervention\Gif\Exceptions\EncoderException;
|
||||
|
||||
class ColorTableEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(ColorTable $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', array_map(
|
||||
fn(Color $color): string => $color->encode(),
|
||||
$this->entity->colors(),
|
||||
));
|
||||
}
|
||||
}
|
||||
41
vendor/intervention/gif/src/Encoders/CommentExtensionEncoder.php
vendored
Normal file
41
vendor/intervention/gif/src/Encoders/CommentExtensionEncoder.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\CommentExtension;
|
||||
|
||||
class CommentExtensionEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new decoder instance.
|
||||
*/
|
||||
public function __construct(CommentExtension $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
CommentExtension::MARKER,
|
||||
CommentExtension::LABEL,
|
||||
$this->encodeComments(),
|
||||
CommentExtension::TERMINATOR,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode comment blocks.
|
||||
*/
|
||||
private function encodeComments(): string
|
||||
{
|
||||
return implode('', array_map(function (string $comment): string {
|
||||
return pack('C', strlen($comment)) . $comment;
|
||||
}, $this->entity->comments()));
|
||||
}
|
||||
}
|
||||
26
vendor/intervention/gif/src/Encoders/DataSubBlockEncoder.php
vendored
Normal file
26
vendor/intervention/gif/src/Encoders/DataSubBlockEncoder.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\DataSubBlock;
|
||||
|
||||
class DataSubBlockEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(DataSubBlock $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return pack('C', $this->entity->size()) . $this->entity->value();
|
||||
}
|
||||
}
|
||||
49
vendor/intervention/gif/src/Encoders/FrameBlockEncoder.php
vendored
Normal file
49
vendor/intervention/gif/src/Encoders/FrameBlockEncoder.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\ApplicationExtension;
|
||||
use Intervention\Gif\Blocks\CommentExtension;
|
||||
use Intervention\Gif\Blocks\FrameBlock;
|
||||
use Intervention\Gif\Exceptions\EncoderException;
|
||||
|
||||
class FrameBlockEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new decoder instance.
|
||||
*/
|
||||
public function __construct(FrameBlock $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
$graphicControlExtension = $this->entity->graphicControlExtension();
|
||||
$colorTable = $this->entity->colorTable();
|
||||
$plainTextExtension = $this->entity->plainTextExtension();
|
||||
|
||||
return implode('', [
|
||||
implode('', array_map(
|
||||
fn(ApplicationExtension $extension): string => $extension->encode(),
|
||||
$this->entity->applicationExtensions(),
|
||||
)),
|
||||
implode('', array_map(
|
||||
fn(CommentExtension $extension): string => $extension->encode(),
|
||||
$this->entity->commentExtensions(),
|
||||
)),
|
||||
$plainTextExtension ? $plainTextExtension->encode() : '',
|
||||
$graphicControlExtension ? $graphicControlExtension->encode() : '',
|
||||
$this->entity->imageDescriptor()->encode(),
|
||||
$colorTable ? $colorTable->encode() : '',
|
||||
$this->entity->imageData()->encode(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
76
vendor/intervention/gif/src/Encoders/GifDataStreamEncoder.php
vendored
Normal file
76
vendor/intervention/gif/src/Encoders/GifDataStreamEncoder.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\CommentExtension;
|
||||
use Intervention\Gif\Blocks\FrameBlock;
|
||||
use Intervention\Gif\Exceptions\EncoderException;
|
||||
use Intervention\Gif\GifDataStream;
|
||||
|
||||
class GifDataStreamEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(GifDataStream $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
$this->entity->header()->encode(),
|
||||
$this->entity->logicalScreenDescriptor()->encode(),
|
||||
$this->maybeEncodeGlobalColorTable(),
|
||||
$this->encodeFrames(),
|
||||
$this->encodeComments(),
|
||||
$this->entity->trailer()->encode(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode global color table if present in gif data.
|
||||
*/
|
||||
private function maybeEncodeGlobalColorTable(): string
|
||||
{
|
||||
if (!$this->entity->hasGlobalColorTable()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->entity->globalColorTable()->encode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode data blocks of source.
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
private function encodeFrames(): string
|
||||
{
|
||||
return implode('', array_map(
|
||||
fn(FrameBlock $frame): string => $frame->encode(),
|
||||
$this->entity->frames(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode comment extension blocks of source.
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
private function encodeComments(): string
|
||||
{
|
||||
return implode('', array_map(
|
||||
fn(CommentExtension $commentExtension): string => $commentExtension->encode(),
|
||||
$this->entity->comments()
|
||||
));
|
||||
}
|
||||
}
|
||||
63
vendor/intervention/gif/src/Encoders/GraphicControlExtensionEncoder.php
vendored
Normal file
63
vendor/intervention/gif/src/Encoders/GraphicControlExtensionEncoder.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\GraphicControlExtension;
|
||||
|
||||
class GraphicControlExtensionEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(GraphicControlExtension $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
GraphicControlExtension::MARKER,
|
||||
GraphicControlExtension::LABEL,
|
||||
GraphicControlExtension::BLOCKSIZE,
|
||||
$this->encodePackedField(),
|
||||
$this->encodeDelay(),
|
||||
$this->encodeTransparentColorIndex(),
|
||||
GraphicControlExtension::TERMINATOR,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode delay time.
|
||||
*/
|
||||
private function encodeDelay(): string
|
||||
{
|
||||
return pack('v*', $this->entity->delay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode transparent color index.
|
||||
*/
|
||||
private function encodeTransparentColorIndex(): string
|
||||
{
|
||||
return pack('C', $this->entity->transparentColorIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode packed field.
|
||||
*/
|
||||
private function encodePackedField(): string
|
||||
{
|
||||
return pack('C', bindec(implode('', [
|
||||
str_pad('0', 3, '0', STR_PAD_LEFT),
|
||||
str_pad(decbin($this->entity->disposalMethod()->value), 3, '0', STR_PAD_LEFT),
|
||||
(int) $this->entity->userInput(),
|
||||
(int) $this->entity->transparentColorExistance(),
|
||||
])));
|
||||
}
|
||||
}
|
||||
26
vendor/intervention/gif/src/Encoders/HeaderEncoder.php
vendored
Normal file
26
vendor/intervention/gif/src/Encoders/HeaderEncoder.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\Header;
|
||||
|
||||
class HeaderEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(Header $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return Header::SIGNATURE . $this->entity->version();
|
||||
}
|
||||
}
|
||||
44
vendor/intervention/gif/src/Encoders/ImageDataEncoder.php
vendored
Normal file
44
vendor/intervention/gif/src/Encoders/ImageDataEncoder.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\AbstractEntity;
|
||||
use Intervention\Gif\Blocks\DataSubBlock;
|
||||
use Intervention\Gif\Blocks\ImageData;
|
||||
use Intervention\Gif\Exceptions\EncoderException;
|
||||
use Intervention\Gif\Exceptions\StateException;
|
||||
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
95
vendor/intervention/gif/src/Encoders/ImageDescriptorEncoder.php
vendored
Normal file
95
vendor/intervention/gif/src/Encoders/ImageDescriptorEncoder.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\ImageDescriptor;
|
||||
|
||||
class ImageDescriptorEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(ImageDescriptor $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
ImageDescriptor::SEPARATOR,
|
||||
$this->encodeLeft(),
|
||||
$this->encodeTop(),
|
||||
$this->encodeWidth(),
|
||||
$this->encodeHeight(),
|
||||
$this->encodePackedField(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode left value.
|
||||
*/
|
||||
private function encodeLeft(): string
|
||||
{
|
||||
return pack('v*', $this->entity->left());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode top value.
|
||||
*/
|
||||
private function encodeTop(): string
|
||||
{
|
||||
return pack('v*', $this->entity->top());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode width value.
|
||||
*/
|
||||
private function encodeWidth(): string
|
||||
{
|
||||
return pack('v*', $this->entity->width());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode height value.
|
||||
*/
|
||||
private function encodeHeight(): string
|
||||
{
|
||||
return pack('v*', $this->entity->height());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode size of local color table.
|
||||
*/
|
||||
private function encodeLocalColorTableSize(): string
|
||||
{
|
||||
return str_pad(decbin($this->entity->localColorTableSize()), 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode reserved field.
|
||||
*/
|
||||
private function encodeReservedField(): string
|
||||
{
|
||||
return str_pad('0', 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode packed field.
|
||||
*/
|
||||
private function encodePackedField(): string
|
||||
{
|
||||
return pack('C', bindec(implode('', [
|
||||
(int) $this->entity->localColorTableExistance(),
|
||||
(int) $this->entity->isInterlaced(),
|
||||
(int) $this->entity->localColorTableSorted(),
|
||||
$this->encodeReservedField(),
|
||||
$this->encodeLocalColorTableSize(),
|
||||
])));
|
||||
}
|
||||
}
|
||||
93
vendor/intervention/gif/src/Encoders/LogicalScreenDescriptorEncoder.php
vendored
Normal file
93
vendor/intervention/gif/src/Encoders/LogicalScreenDescriptorEncoder.php
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\LogicalScreenDescriptor;
|
||||
|
||||
class LogicalScreenDescriptorEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(LogicalScreenDescriptor $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
$this->encodeWidth(),
|
||||
$this->encodeHeight(),
|
||||
$this->encodePackedField(),
|
||||
$this->encodeBackgroundColorIndex(),
|
||||
$this->encodePixelAspectRatio(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode width of current instance.
|
||||
*/
|
||||
private function encodeWidth(): string
|
||||
{
|
||||
return pack('v*', $this->entity->width());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode height of current instance.
|
||||
*/
|
||||
private function encodeHeight(): string
|
||||
{
|
||||
return pack('v*', $this->entity->height());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode background color index of global color table.
|
||||
*/
|
||||
private function encodeBackgroundColorIndex(): string
|
||||
{
|
||||
return pack('C', $this->entity->backgroundColorIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode pixel aspect ratio.
|
||||
*/
|
||||
private function encodePixelAspectRatio(): string
|
||||
{
|
||||
return pack('C', $this->entity->pixelAspectRatio());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return color resolution for encoding.
|
||||
*/
|
||||
private function encodeColorResolution(): string
|
||||
{
|
||||
return str_pad(decbin($this->entity->bitsPerPixel() - 1), 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode size of global color table.
|
||||
*/
|
||||
private function encodeGlobalColorTableSize(): string
|
||||
{
|
||||
return str_pad(decbin($this->entity->globalColorTableSize()), 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode packed field of current instance.
|
||||
*/
|
||||
private function encodePackedField(): string
|
||||
{
|
||||
return pack('C', bindec(implode('', [
|
||||
(int) $this->entity->globalColorTableExistance(),
|
||||
$this->encodeColorResolution(),
|
||||
(int) $this->entity->globalColorTableSorted(),
|
||||
$this->encodeGlobalColorTableSize(),
|
||||
])));
|
||||
}
|
||||
}
|
||||
38
vendor/intervention/gif/src/Encoders/NetscapeApplicationExtensionEncoder.php
vendored
Normal file
38
vendor/intervention/gif/src/Encoders/NetscapeApplicationExtensionEncoder.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\ApplicationExtension;
|
||||
use Intervention\Gif\Blocks\DataSubBlock;
|
||||
use Intervention\Gif\Blocks\NetscapeApplicationExtension;
|
||||
use Intervention\Gif\Exceptions\EncoderException;
|
||||
|
||||
class NetscapeApplicationExtensionEncoder extends ApplicationExtensionEncoder
|
||||
{
|
||||
/**
|
||||
* Create new decoder instance.
|
||||
*/
|
||||
public function __construct(NetscapeApplicationExtension $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current source.
|
||||
*
|
||||
* @throws EncoderException
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
ApplicationExtension::MARKER,
|
||||
ApplicationExtension::LABEL,
|
||||
pack('C', $this->entity->blockSize()),
|
||||
$this->entity->application(),
|
||||
implode('', array_map(fn(DataSubBlock $block): string => $block->encode(), $this->entity->blocks())),
|
||||
ApplicationExtension::TERMINATOR,
|
||||
]);
|
||||
}
|
||||
}
|
||||
55
vendor/intervention/gif/src/Encoders/PlainTextExtensionEncoder.php
vendored
Normal file
55
vendor/intervention/gif/src/Encoders/PlainTextExtensionEncoder.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\PlainTextExtension;
|
||||
|
||||
class PlainTextExtensionEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(PlainTextExtension $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
if (!$this->entity->hasText()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return implode('', [
|
||||
PlainTextExtension::MARKER,
|
||||
PlainTextExtension::LABEL,
|
||||
$this->encodeHead(),
|
||||
$this->encodeTexts(),
|
||||
PlainTextExtension::TERMINATOR,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode head block.
|
||||
*/
|
||||
private function encodeHead(): string
|
||||
{
|
||||
return "\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode text chunks.
|
||||
*/
|
||||
private function encodeTexts(): string
|
||||
{
|
||||
return implode('', array_map(
|
||||
fn(string $text): string => pack('C', strlen($text)) . $text,
|
||||
$this->entity->text(),
|
||||
));
|
||||
}
|
||||
}
|
||||
30
vendor/intervention/gif/src/Encoders/TableBasedImageEncoder.php
vendored
Normal file
30
vendor/intervention/gif/src/Encoders/TableBasedImageEncoder.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\TableBasedImage;
|
||||
|
||||
class TableBasedImageEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(TableBasedImage $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return implode('', [
|
||||
$this->entity->imageDescriptor()->encode(),
|
||||
$this->entity->colorTable() ? $this->entity->colorTable()->encode() : '',
|
||||
$this->entity->imageData()->encode(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
vendor/intervention/gif/src/Encoders/TrailerEncoder.php
vendored
Normal file
26
vendor/intervention/gif/src/Encoders/TrailerEncoder.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Gif\Encoders;
|
||||
|
||||
use Intervention\Gif\Blocks\Trailer;
|
||||
|
||||
class TrailerEncoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Create new instance.
|
||||
*/
|
||||
public function __construct(Trailer $entity)
|
||||
{
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode current entity.
|
||||
*/
|
||||
public function encode(): string
|
||||
{
|
||||
return Trailer::MARKER;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user