first commit

This commit is contained in:
Ariyutta
2026-08-07 10:47:09 +07:00
commit 1c094fbe7f
11630 changed files with 1580900 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Intervention\Gif\Traits;
use Intervention\Gif\Encoders\AbstractEncoder;
use Intervention\Gif\Exceptions\EncoderException;
trait CanEncode
{
/**
* Encode current entity
*
* @throws EncoderException
*/
public function encode(): string
{
return $this->getEncoder()->encode();
}
/**
* Get encoder object for current entity
*
* @throws EncoderException
*/
protected function getEncoder(): AbstractEncoder
{
$classname = sprintf('Intervention\Gif\Encoders\%sEncoder', $this->getShortClassname());
if (!class_exists($classname)) {
throw new EncoderException("Encoder for '" . $this::class . "' not found.");
}
$encoder = new $classname($this);
if (!($encoder instanceof AbstractEncoder)) {
throw new EncoderException("Encoder for '" . $this::class . "' not found.");
}
return $encoder;
}
}