Skip to content

Commit

Permalink
Add interface for GenericData & EncodedImage
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Nov 4, 2023
1 parent aae6d35 commit 8f73dd8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/EncodedImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/GenericData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/Interfaces/EncodedImageInterface.php
Original file line number Diff line number Diff line change
@@ -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 changes: 42 additions & 0 deletions src/Interfaces/GenericDataInterface.php
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 8f73dd8

Please sign in to comment.