mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 09:31:53 +02:00
Move method from trait to AbstractDecoder
This commit is contained in:
@@ -44,7 +44,7 @@ abstract class AbstractDecoder implements DecoderInterface
|
||||
|
||||
protected function decodeExifData(string $image_data): array
|
||||
{
|
||||
if (! function_exists('exif_read_data')) {
|
||||
if (!function_exists('exif_read_data')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -60,4 +60,13 @@ abstract class AbstractDecoder implements DecoderInterface
|
||||
|
||||
return is_array($data) ? $data : [];
|
||||
}
|
||||
|
||||
protected function isValidBase64($input): bool
|
||||
{
|
||||
if (!is_string($input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return base64_encode(base64_decode($input)) === str_replace(["\n", "\r"], '', $input);
|
||||
}
|
||||
}
|
||||
|
@@ -6,12 +6,9 @@ use Intervention\Image\Exceptions\DecoderException;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Intervention\Image\Interfaces\DecoderInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Traits\CanValidateBase64;
|
||||
|
||||
class Base64ImageDecoder extends BinaryImageDecoder implements DecoderInterface
|
||||
{
|
||||
use CanValidateBase64;
|
||||
|
||||
public function decode($input): ImageInterface|ColorInterface
|
||||
{
|
||||
if (! $this->isValidBase64($input)) {
|
||||
|
@@ -6,12 +6,9 @@ use Intervention\Image\Exceptions\DecoderException;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Intervention\Image\Interfaces\DecoderInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Traits\CanValidateBase64;
|
||||
|
||||
class Base64ImageDecoder extends BinaryImageDecoder implements DecoderInterface
|
||||
{
|
||||
use CanValidateBase64;
|
||||
|
||||
public function decode($input): ImageInterface|ColorInterface
|
||||
{
|
||||
if (! $this->isValidBase64($input)) {
|
||||
|
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Traits;
|
||||
|
||||
trait CanValidateBase64
|
||||
{
|
||||
protected function isValidBase64($input): bool
|
||||
{
|
||||
if (! is_string($input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return base64_encode(base64_decode($input)) === str_replace(["\n", "\r"], '', $input);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user