1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-21 13:11:18 +02:00

Add interface for GenericData & EncodedImage

This commit is contained in:
Oliver Vogel
2023-11-04 16:08:00 +01:00
parent aae6d359aa
commit 8f73dd81b7
4 changed files with 67 additions and 2 deletions

View File

@@ -2,7 +2,9 @@
namespace Intervention\Image;
class EncodedImage extends GenericData
use Intervention\Image\Interfaces\EncodedImageInterface;
class EncodedImage extends GenericData implements EncodedImageInterface
{
/**
* Create new instance

View File

@@ -3,8 +3,9 @@
namespace Intervention\Image;
use Intervention\Image\Exceptions\NotWritableException;
use Intervention\Image\Interfaces\GenericDataInterface;
class GenericData
class GenericData implements GenericDataInterface
{
/**
* Create new instance

View File

@@ -0,0 +1,20 @@
<?php
namespace Intervention\Image\Interfaces;
interface EncodedImageInterface extends GenericDataInterface
{
/**
* Return Media (MIME) Type of encoded image
*
* @return string
*/
public function mimetype(): string;
/**
* Turn encoded image into DataUri format
*
* @return string
*/
public function toDataUri(): string;
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Intervention\Image\Interfaces;
interface GenericDataInterface
{
/**
* Save data in given path in file system
*
* @param string $filepath
* @return void
*/
public function save(string $filepath): void;
/**
* Create file pointer from encoded data
*
* @return resource
*/
public function toFilePointer();
/**
* Return size in bytes
*
* @return int
*/
public function size(): int;
/**
* Turn encoded data into string
*
* @return string
*/
public function toString(): string;
/**
* Cast encoded data into string
*
* @return string
*/
public function __toString(): string;
}