mirror of
https://github.com/Intervention/image.git
synced 2025-08-22 13:32:56 +02:00
Add interface for GenericData & EncodedImage
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Intervention\Image;
|
namespace Intervention\Image;
|
||||||
|
|
||||||
class EncodedImage extends GenericData
|
use Intervention\Image\Interfaces\EncodedImageInterface;
|
||||||
|
|
||||||
|
class EncodedImage extends GenericData implements EncodedImageInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create new instance
|
* Create new instance
|
||||||
|
@@ -3,8 +3,9 @@
|
|||||||
namespace Intervention\Image;
|
namespace Intervention\Image;
|
||||||
|
|
||||||
use Intervention\Image\Exceptions\NotWritableException;
|
use Intervention\Image\Exceptions\NotWritableException;
|
||||||
|
use Intervention\Image\Interfaces\GenericDataInterface;
|
||||||
|
|
||||||
class GenericData
|
class GenericData implements GenericDataInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create new instance
|
* Create new instance
|
||||||
|
20
src/Interfaces/EncodedImageInterface.php
Normal file
20
src/Interfaces/EncodedImageInterface.php
Normal 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;
|
||||||
|
}
|
42
src/Interfaces/GenericDataInterface.php
Normal file
42
src/Interfaces/GenericDataInterface.php
Normal 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;
|
||||||
|
}
|
Reference in New Issue
Block a user