Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/EncodedImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
use Intervention\Image\Exceptions\StreamException;
use Intervention\Image\Interfaces\DataUriInterface;
use Intervention\Image\Interfaces\EncodedImageInterface;
use JsonSerializable;
use Throwable;

class EncodedImage extends File implements EncodedImageInterface, JsonSerializable
class EncodedImage extends File implements EncodedImageInterface
{
/**
* Create new instance.
Expand Down Expand Up @@ -74,18 +73,6 @@ public function toBase64(): string
return base64_encode((string) $this);
}

/**
* {@inheritdoc}
*
* @see JsonSerializable::jsonSerialize()
*
* @throws StreamException
*/
public function jsonSerialize(): mixed
{
return $this->toDataUri();
}

/**
* Show debug info for the current image.
*
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/EncodedImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Intervention\Image\Tests\Unit;

use JsonSerializable;
use PHPUnit\Framework\Attributes\CoversClass;
use Intervention\Image\EncodedImage;
use Intervention\Image\Tests\BaseTestCase;
Expand Down Expand Up @@ -52,10 +53,11 @@ public function testToString(): void
$this->assertEquals('foo', (string) $image);
}

public function testJsonSerialze(): void
public function testNotJsonSerializable(): void
{
// Frameworks like Laravel force application/json responses for JsonSerializable content.
$image = new EncodedImage('foo');
$this->assertEquals('["data:application\/octet-stream;base64,Zm9v"]', json_encode([$image]));
$this->assertNotInstanceOf(JsonSerializable::class, $image);
}

public function testMediaType(): void
Expand Down