Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s

- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3)
- Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung
- Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü
- Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person
- Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“
- Benutzerverwaltung im Admin, Zugang vorläufig über is_admin
- vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/
- PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung
- VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-25 20:35:30 +00:00
parent 7197eaebf2
commit 9c0f8de791
15771 changed files with 1564103 additions and 5 deletions

View file

@ -0,0 +1,97 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractExtension;
use Intervention\Gif\Exceptions\StateException;
class ApplicationExtension extends AbstractExtension
{
public const LABEL = "\xFF";
/**
* Application Identifier & Auth Code.
*/
protected string $application = '';
/**
* Data Sub Blocks.
*
* @var array<DataSubBlock>
*/
protected array $blocks = [];
/**
* Get size of block.
*/
public function blockSize(): int
{
return strlen($this->application);
}
/**
* Set application name.
*/
public function setApplication(string $value): self
{
$this->application = $value;
return $this;
}
/**
* Get application name.
*/
public function application(): string
{
return $this->application;
}
/**
* Add block to application extension.
*/
public function addBlock(DataSubBlock $block): self
{
$this->blocks[] = $block;
return $this;
}
/**
* Set data sub blocks of instance.
*
* @param array<DataSubBlock> $blocks
*/
public function setBlocks(array $blocks): self
{
$this->blocks = $blocks;
return $this;
}
/**
* Get blocks of ApplicationExtension.
*
* @return array<DataSubBlock>
*/
public function blocks(): array
{
return $this->blocks;
}
/**
* Get first block of ApplicationExtension.
*
* @throws StateException
*/
public function firstBlock(): DataSubBlock
{
if (!array_key_exists(0, $this->blocks)) {
throw new StateException('Failed to retrieve data sub block');
}
return $this->blocks[0];
}
}

View file

@ -0,0 +1,96 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
use Intervention\Gif\Exceptions\InvalidArgumentException;
class Color extends AbstractEntity
{
/**
* Create new instance.
*
* @throws InvalidArgumentException
*/
public function __construct(
protected int $r = 0,
protected int $g = 0,
protected int $b = 0
) {
if ($r < 0 || $r > 255) {
throw new InvalidArgumentException('Color channel red must be in range 0 to 255');
}
if ($g < 0 || $g > 255) {
throw new InvalidArgumentException('Color channel green must be in range 0 to 255');
}
if ($b < 0 || $b > 255) {
throw new InvalidArgumentException('Color channel blue must be in range 0 to 255');
}
}
/**
* Get red value.
*/
public function red(): int
{
return $this->r;
}
/**
* Set red value.
*/
public function setRed(int $value): self
{
$this->r = $value;
return $this;
}
/**
* Get green value.
*/
public function green(): int
{
return $this->g;
}
/**
* Set green value.
*/
public function setGreen(int $value): self
{
$this->g = $value;
return $this;
}
/**
* Get blue value.
*/
public function blue(): int
{
return $this->b;
}
/**
* Set blue value.
*/
public function setBlue(int $value): self
{
$this->b = $value;
return $this;
}
/**
* Return hash value of current color.
*/
public function hash(): string
{
return md5(strval($this->r . $this->g . $this->b));
}
}

View file

@ -0,0 +1,123 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
use Intervention\Gif\Exceptions\InvalidArgumentException;
class ColorTable extends AbstractEntity
{
/**
* Create new instance.
*
* @param array<Color> $colors
*/
public function __construct(protected array $colors = [])
{
//
}
/**
* Return array of current colors.
*
* @return array<Color>
*/
public function colors(): array
{
return array_values($this->colors);
}
/**
* Add color to table.
*
* @throws InvalidArgumentException
*/
public function addRgb(int $r, int $g, int $b): self
{
$this->addColor(new Color($r, $g, $b));
return $this;
}
/**
* Add color to table.
*/
public function addColor(Color $color): self
{
$this->colors[] = $color;
return $this;
}
/**
* Reset colors to array of color objects.
*
* @param array<Color> $colors
*/
public function setColors(array $colors): self
{
$this->empty();
foreach ($colors as $color) {
$this->addColor($color);
}
return $this;
}
/**
* Count colors of current instance.
*/
public function countColors(): int
{
return count($this->colors);
}
/**
* Determine if any colors are present on the current table
*/
public function hasColors(): bool
{
return $this->countColors() >= 1;
}
/**
* Empty color table.
*/
public function empty(): self
{
$this->colors = [];
return $this;
}
/**
* Get size of color table in logical screen descriptor.
*/
public function logicalSize(): int
{
return match ($this->countColors()) {
4 => 1,
8 => 2,
16 => 3,
32 => 4,
64 => 5,
128 => 6,
256 => 7,
default => 0,
};
}
/**
* Calculate the number of bytes contained by the current table.
*/
public function byteSize(): int
{
if (!$this->hasColors()) {
return 0;
}
return 3 * pow(2, $this->logicalSize() + 1);
}
}

View file

@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractExtension;
class CommentExtension extends AbstractExtension
{
public const LABEL = "\xFE";
/**
* Comment blocks.
*
* @var array<string>
*/
protected array $comments = [];
/**
* Get all or one comment.
*
* @return array<string>
*/
public function comments(): array
{
return $this->comments;
}
/**
* Get one comment by key.
*/
public function comment(int $key): mixed
{
return $this->comments[$key] ?? null;
}
/**
* Set comment text.
*/
public function addComment(string $value): self
{
$this->comments[] = $value;
return $this;
}
}

View file

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
use Intervention\Gif\Exceptions\InvalidArgumentException;
class DataSubBlock extends AbstractEntity
{
/**
* Create new instance.
*
* @throws InvalidArgumentException
*/
public function __construct(protected string $value)
{
if ($this->size() > 255) {
throw new InvalidArgumentException(
'Data Sub-Block can not have a block size larger than 255 bytes'
);
}
}
/**
* Return size of current block.
*/
public function size(): int
{
return strlen($this->value);
}
/**
* Return block value.
*/
public function value(): string
{
return $this->value;
}
}

View file

@ -0,0 +1,254 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
/**
* The GIF files that can be found on the Internet come in a wide variety
* of forms. Some strictly adhere to the original specification, others do
* not and differ in the actual sequence of blocks or their number.
*
* For this reason, this libary has this (kind of "virtual") FrameBlock,
* which can contain all possible blocks in different order that occur in
* a GIF animation.
*
* - Image Description
* - Local Color Table
* - Image Data Block
* - Plain Text Extension
* - Application Extension
* - Comment Extension
*
* The TableBasedImage block, which is a chain of ImageDescriptor, (Local
* Color Table) and ImageData, is used as a marker for terminating a
* FrameBlock.
*
* So far I have only seen GIF files that follow this scheme. However, there are
* examples which have one (or more) comment extensions added before the end. So
* there can be additional "global comments" that are not part of the FrameBlock
* and are appended to the GifDataStream afterwards.
*/
class FrameBlock extends AbstractEntity
{
protected ?GraphicControlExtension $graphicControlExtension = null;
protected ?ColorTable $colorTable = null;
protected ?PlainTextExtension $plainTextExtension = null;
/**
* @var array<ApplicationExtension> $applicationExtensions
*/
protected array $applicationExtensions = [];
/**
* @var array<CommentExtension> $commentExtensions
*/
protected array $commentExtensions = [];
public function __construct(
protected ImageDescriptor $imageDescriptor = new ImageDescriptor(),
protected ImageData $imageData = new ImageData()
) {
//
}
/**
* Add entity to block.
*/
public function addEntity(AbstractEntity $entity): self
{
return match (true) {
$entity instanceof TableBasedImage => $this->setTableBasedImage($entity),
$entity instanceof GraphicControlExtension => $this->setGraphicControlExtension($entity),
$entity instanceof ImageDescriptor => $this->setImageDescriptor($entity),
$entity instanceof ColorTable => $this->setColorTable($entity),
$entity instanceof ImageData => $this->setImageData($entity),
$entity instanceof PlainTextExtension => $this->setPlainTextExtension($entity),
$entity instanceof NetscapeApplicationExtension,
$entity instanceof ApplicationExtension => $this->addApplicationExtension($entity),
$entity instanceof CommentExtension => $this->addCommentExtension($entity),
default => $this,
};
}
/**
* Return application extensions of current frame block.
*
* @return array<ApplicationExtension>
*/
public function applicationExtensions(): array
{
return $this->applicationExtensions;
}
/**
* Return comment extensions of current frame block.
*
* @return array<CommentExtension>
*/
public function commentExtensions(): array
{
return $this->commentExtensions;
}
/**
* Set the graphic control extension.
*/
public function setGraphicControlExtension(GraphicControlExtension $extension): self
{
$this->graphicControlExtension = $extension;
return $this;
}
/**
* Get the graphic control extension of the current frame block.
*/
public function graphicControlExtension(): ?GraphicControlExtension
{
return $this->graphicControlExtension;
}
/**
* Set the image descriptor.
*/
public function setImageDescriptor(ImageDescriptor $descriptor): self
{
$this->imageDescriptor = $descriptor;
return $this;
}
/**
* Get the image descriptor of the frame block.
*/
public function imageDescriptor(): ImageDescriptor
{
return $this->imageDescriptor;
}
/**
* Set the color table of the current frame block.
*/
public function setColorTable(ColorTable $table): self
{
$this->colorTable = $table;
return $this;
}
/**
* Get color table.
*/
public function colorTable(): ?ColorTable
{
return $this->colorTable;
}
/**
* Determine if frame block has color table.
*/
public function hasColorTable(): bool
{
return !is_null($this->colorTable);
}
/**
* Set image data of frame block.
*/
public function setImageData(ImageData $data): self
{
$this->imageData = $data;
return $this;
}
/**
* Get image data of current frame block.
*/
public function imageData(): ImageData
{
return $this->imageData;
}
/**
* Set plain text extension.
*/
public function setPlainTextExtension(PlainTextExtension $extension): self
{
$this->plainTextExtension = $extension;
return $this;
}
/**
* Get plain text extension.
*/
public function plainTextExtension(): ?PlainTextExtension
{
return $this->plainTextExtension;
}
/**
* Add given application extension to the current frame block.
*/
public function addApplicationExtension(ApplicationExtension $extension): self
{
$this->applicationExtensions[] = $extension;
return $this;
}
/**
* Remove all application extensions from the current frame block.
*/
public function clearApplicationExtensions(): self
{
$this->applicationExtensions = [];
return $this;
}
/**
* Add given comment extension to the current frame block
*/
public function addCommentExtension(CommentExtension $extension): self
{
$this->commentExtensions[] = $extension;
return $this;
}
/**
* Return netscape extension of the frame block if available.
*/
public function netscapeExtension(): ?NetscapeApplicationExtension
{
$extensions = array_filter(
$this->applicationExtensions,
fn(ApplicationExtension $extension): bool => $extension instanceof NetscapeApplicationExtension,
);
return count($extensions) > 0 ? reset($extensions) : null;
}
/**
* Set the table based image of the current frame block.
*/
public function setTableBasedImage(TableBasedImage $tableBasedImage): self
{
$this->setImageDescriptor($tableBasedImage->imageDescriptor());
$colorTable = $tableBasedImage->colorTable();
if ($colorTable !== null) {
$this->setColorTable($colorTable);
}
$this->setImageData($tableBasedImage->imageData());
return $this;
}
}

View file

@ -0,0 +1,129 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractExtension;
use Intervention\Gif\DisposalMethod;
class GraphicControlExtension extends AbstractExtension
{
public const LABEL = "\xF9";
public const BLOCKSIZE = "\x04";
/**
* Existance flag of transparent color.
*/
protected bool $transparentColorExistance = false;
/**
* Transparent color index.
*/
protected int $transparentColorIndex = 0;
/**
* User input flag.
*/
protected bool $userInput = false;
/**
* Create new instance.
*/
public function __construct(
protected int $delay = 0,
protected DisposalMethod $disposalMethod = DisposalMethod::UNDEFINED,
) {
//
}
/**
* Set delay time (1/100 second).
*/
public function setDelay(int $value): self
{
$this->delay = $value;
return $this;
}
/**
* Return delay time (1/100 second).
*/
public function delay(): int
{
return $this->delay;
}
/**
* Set disposal method.
*/
public function setDisposalMethod(DisposalMethod $method): self
{
$this->disposalMethod = $method;
return $this;
}
/**
* Get disposal method.
*/
public function disposalMethod(): DisposalMethod
{
return $this->disposalMethod;
}
/**
* Get transparent color index.
*/
public function transparentColorIndex(): int
{
return $this->transparentColorIndex;
}
/**
* Set transparent color index.
*/
public function setTransparentColorIndex(int $index): self
{
$this->transparentColorIndex = $index;
return $this;
}
/**
* Get current transparent color existance.
*/
public function transparentColorExistance(): bool
{
return $this->transparentColorExistance;
}
/**
* Set existance flag of transparent color.
*/
public function setTransparentColorExistance(bool $existance = true): self
{
$this->transparentColorExistance = $existance;
return $this;
}
/**
* Get user input flag.
*/
public function userInput(): bool
{
return $this->userInput;
}
/**
* Set user input flag.
*/
public function setUserInput(bool $value = true): self
{
$this->userInput = $value;
return $this;
}
}

View file

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
class Header extends AbstractEntity
{
/**
* Header signature.
*/
public const SIGNATURE = 'GIF';
/**
* Current GIF version.
*/
protected string $version = '89a';
/**
* Set GIF version.
*/
public function setVersion(string $value): self
{
$this->version = $value;
return $this;
}
/**
* Return current version.
*/
public function version(): string
{
return $this->version;
}
}

View file

@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
class ImageData extends AbstractEntity
{
/**
* LZW min. code size.
*/
protected int $lzwMinCodeSize;
/**
* Sub blocks.
*
* @var array<DataSubBlock>
*/
protected array $blocks = [];
/**
* Get LZW min. code size.
*/
public function lzwMinCodeSize(): int
{
return $this->lzwMinCodeSize;
}
/**
* Set lzw min. code size.
*/
public function setLzwMinCodeSize(int $size): self
{
$this->lzwMinCodeSize = $size;
return $this;
}
/**
* Get current data sub blocks.
*
* @return array<DataSubBlock>
*/
public function blocks(): array
{
return $this->blocks;
}
/**
* Addd sub block.
*/
public function addBlock(DataSubBlock $block): self
{
$this->blocks[] = $block;
return $this;
}
/**
* Determine if data sub blocks are present.
*/
public function hasBlocks(): bool
{
return count($this->blocks) >= 1;
}
}

View file

@ -0,0 +1,205 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
use Intervention\Gif\Exceptions\InvalidArgumentException;
class ImageDescriptor extends AbstractEntity
{
public const SEPARATOR = "\x2C";
/**
* Width of frame.
*/
protected int $width = 0;
/**
* Height of frame.
*/
protected int $height = 0;
/**
* Left position of frame.
*/
protected int $left = 0;
/**
* Top position of frame.
*/
protected int $top = 0;
/**
* Determine if frame is interlaced.
*/
protected bool $interlaced = false;
/**
* Local color table flag.
*/
protected bool $localColorTableExistance = false;
/**
* Sort flag of local color table.
*/
protected bool $localColorTableSorted = false;
/**
* Size of local color table.
*/
protected int $localColorTableSize = 0;
/**
* Get current width.
*/
public function width(): int
{
return $this->width;
}
/**
* Get current width.
*/
public function height(): int
{
return $this->height;
}
/**
* Get current Top.
*/
public function top(): int
{
return $this->top;
}
/**
* Get current Left.
*/
public function left(): int
{
return $this->left;
}
/**
* Set size of current instance.
*
* @throws InvalidArgumentException
*/
public function setSize(int $width, int $height): self
{
if ($width <= 0) {
throw new InvalidArgumentException('Width in ' . $this::class . ' must be larger than 0');
}
if ($height <= 0) {
throw new InvalidArgumentException('Height in ' . $this::class . ' must be larger than 0');
}
$this->width = $width;
$this->height = $height;
return $this;
}
/**
* Set position of current instance.
*/
public function setPosition(int $left, int $top): self
{
$this->left = $left;
$this->top = $top;
return $this;
}
/**
* Determine if frame is interlaced.
*/
public function isInterlaced(): bool
{
return $this->interlaced;
}
/**
* Set or unset interlaced value.
*/
public function setInterlaced(bool $value = true): self
{
$this->interlaced = $value;
return $this;
}
/**
* Determine if local color table is present.
*/
public function localColorTableExistance(): bool
{
return $this->localColorTableExistance;
}
/**
* Alias for localColorTableExistance.
*/
public function hasLocalColorTable(): bool
{
return $this->localColorTableExistance();
}
/**
* Set local color table flag.
*/
public function setLocalColorTableExistance(bool $existance = true): self
{
$this->localColorTableExistance = $existance;
return $this;
}
/**
* Get local color table sorted flag.
*/
public function localColorTableSorted(): bool
{
return $this->localColorTableSorted;
}
/**
* Set local color table sorted flag.
*/
public function setLocalColorTableSorted(bool $sorted = true): self
{
$this->localColorTableSorted = $sorted;
return $this;
}
/**
* Get size of local color table.
*/
public function localColorTableSize(): int
{
return $this->localColorTableSize;
}
/**
* Get byte size of global color table.
*/
public function localColorTableByteSize(): int
{
return 3 * pow(2, $this->localColorTableSize() + 1);
}
/**
* Set size of local color table.
*/
public function setLocalColorTableSize(int $size): self
{
$this->localColorTableSize = $size;
return $this;
}
}

View file

@ -0,0 +1,212 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
use Intervention\Gif\Exceptions\InvalidArgumentException;
class LogicalScreenDescriptor extends AbstractEntity
{
/**
* Width.
*/
protected int $width;
/**
* Height.
*/
protected int $height;
/**
* Global color table flag.
*/
protected bool $globalColorTableExistance = false;
/**
* Sort flag of global color table.
*/
protected bool $globalColorTableSorted = false;
/**
* Size of global color table.
*/
protected int $globalColorTableSize = 0;
/**
* Background color index.
*/
protected int $backgroundColorIndex = 0;
/**
* Color resolution.
*/
protected int $bitsPerPixel = 8;
/**
* Pixel aspect ration.
*/
protected int $pixelAspectRatio = 0;
/**
* Set size.
*
* @throws InvalidArgumentException
*/
public function setSize(int $width, int $height): self
{
if ($width <= 0) {
throw new InvalidArgumentException('Width in ' . $this::class . ' must be larger than 0');
}
if ($height <= 0) {
throw new InvalidArgumentException('Height in ' . $this::class . ' must be larger than 0');
}
$this->width = $width;
$this->height = $height;
return $this;
}
/**
* Get width of current instance.
*/
public function width(): int
{
return $this->width;
}
/**
* Get height of current instance.
*/
public function height(): int
{
return $this->height;
}
/**
* Determine if global color table is present.
*/
public function globalColorTableExistance(): bool
{
return $this->globalColorTableExistance;
}
/**
* Alias of globalColorTableExistance.
*/
public function hasGlobalColorTable(): bool
{
return $this->globalColorTableExistance();
}
/**
* Set global color table flag.
*/
public function setGlobalColorTableExistance(bool $existance = true): self
{
$this->globalColorTableExistance = $existance;
return $this;
}
/**
* Get global color table sorted flag.
*/
public function globalColorTableSorted(): bool
{
return $this->globalColorTableSorted;
}
/**
* Set global color table sorted flag.
*/
public function setGlobalColorTableSorted(bool $sorted = true): self
{
$this->globalColorTableSorted = $sorted;
return $this;
}
/**
* Get size of global color table.
*/
public function globalColorTableSize(): int
{
return $this->globalColorTableSize;
}
/**
* Get byte size of global color table.
*/
public function globalColorTableByteSize(): int
{
return 3 * pow(2, $this->globalColorTableSize() + 1);
}
/**
* Set size of global color table.
*/
public function setGlobalColorTableSize(int $size): self
{
$this->globalColorTableSize = $size;
return $this;
}
/**
* Get background color index.
*/
public function backgroundColorIndex(): int
{
return $this->backgroundColorIndex;
}
/**
* Set background color index.
*/
public function setBackgroundColorIndex(int $index): self
{
$this->backgroundColorIndex = $index;
return $this;
}
/**
* Get current pixel aspect ration.
*/
public function pixelAspectRatio(): int
{
return $this->pixelAspectRatio;
}
/**
* Set pixel aspect ratio.
*/
public function setPixelAspectRatio(int $ratio): self
{
$this->pixelAspectRatio = $ratio;
return $this;
}
/**
* Get color resolution.
*/
public function bitsPerPixel(): int
{
return $this->bitsPerPixel;
}
/**
* Set color resolution.
*/
public function setBitsPerPixel(int $value): self
{
$this->bitsPerPixel = $value;
return $this;
}
}

View file

@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\Exceptions\DecoderException;
use Intervention\Gif\Exceptions\InvalidArgumentException;
use Intervention\Gif\Exceptions\StateException;
class NetscapeApplicationExtension extends ApplicationExtension
{
public const IDENTIFIER = "NETSCAPE";
public const AUTH_CODE = "2.0";
public const SUB_BLOCK_PREFIX = "\x01";
/**
* Create new instance.
*/
public function __construct()
{
try {
$this->setApplication(self::IDENTIFIER . self::AUTH_CODE);
$this->setBlocks([new DataSubBlock(self::SUB_BLOCK_PREFIX . "\x00\x00")]);
} catch (InvalidArgumentException) {
// ignore exception because of hard coded input
}
}
/**
* Get number of loops.
*
* @throws DecoderException
*/
public function loops(): int
{
try {
$unpacked = unpack('v*', substr($this->firstBlock()->value(), 1));
} catch (StateException $e) {
throw new DecoderException(
'Failed to decode loop count of netscape extension',
previous: $e
);
}
if ($unpacked === false || !array_key_exists(1, $unpacked)) {
throw new DecoderException('Failed to calculate loop count');
}
return $unpacked[1];
}
/**
* Set number of loops.
*
* @throws InvalidArgumentException
*/
public function setLoops(int $loops): self
{
$this->setBlocks([
new DataSubBlock(self::SUB_BLOCK_PREFIX . pack('v*', $loops))
]);
return $this;
}
}

View file

@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractExtension;
class PlainTextExtension extends AbstractExtension
{
public const LABEL = "\x01";
/**
* Array of text.
*
* @var array<string>
*/
protected array $text = [];
/**
* Get current text.
*
* @return array<string>
*/
public function text(): array
{
return $this->text;
}
/**
* Add text.
*/
public function addText(string $text): self
{
$this->text[] = $text;
return $this;
}
/**
* Set text array of extension.
*
* @param array<string> $text
*/
public function setText(array $text): self
{
$this->text = $text;
return $this;
}
/**
* Determine if any text is present.
*/
public function hasText(): bool
{
return $this->text !== [];
}
}

View file

@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
class TableBasedImage extends AbstractEntity
{
protected ImageDescriptor $imageDescriptor;
protected ?ColorTable $colorTable = null;
protected ImageData $imageData;
/**
* Get image descriptor.
*/
public function imageDescriptor(): ImageDescriptor
{
return $this->imageDescriptor;
}
/**
* Set image descriptor for current instance.
*/
public function setImageDescriptor(ImageDescriptor $descriptor): self
{
$this->imageDescriptor = $descriptor;
return $this;
}
/**
* Get image data.
*/
public function imageData(): ImageData
{
return $this->imageData;
}
/**
* Set image data for current instance.
*/
public function setImageData(ImageData $data): self
{
$this->imageData = $data;
return $this;
}
/**
* Get current color table or null of table based based image has none.
*/
public function colorTable(): ?ColorTable
{
return $this->colorTable;
}
/**
* Set color table.
*/
public function setColorTable(ColorTable $table): self
{
$this->colorTable = $table;
return $this;
}
}

View file

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Blocks;
use Intervention\Gif\AbstractEntity;
class Trailer extends AbstractEntity
{
public const MARKER = "\x3b";
}