Skip to content

Commit

Permalink
Updated code to follow best PHP practices
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Dec 2, 2020
1 parent ec96cc8 commit 70afaa7
Show file tree
Hide file tree
Showing 14 changed files with 527 additions and 111 deletions.
6 changes: 6 additions & 0 deletions Adapter/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ abstract class Adapter implements AdapterInterface

/**
* The image resource handler.
* @var resource|false
*/
protected $resource;

Expand Down Expand Up @@ -43,6 +44,9 @@ public function getResource()

/**
* Does this adapter supports the given type ?
*
* @param string
* @return bool
*/
protected function supports($type)
{
Expand All @@ -51,6 +55,8 @@ protected function supports($type)

/**
* Converts the image to true color.
*
* @return void
*/
protected function convertToTrueColor()
{
Expand Down
46 changes: 28 additions & 18 deletions Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function setSource(Source $source);
/**
* get the raw resource.
*
* @return resource
* @return resource|null
*/
public function getResource();

Expand Down Expand Up @@ -60,43 +60,53 @@ public function init();

/**
* Unload the resource
*
* @return void
*/
public function deinit();

/**
* Save the image as a gif.
*
* @param string $file
* @return $this
*/
public function saveGif($file);

/**
* Save the image as a png.
*
* @param string $file
* @return $this
*/
public function savePng($file);

/**
* Save the image as a Webp.
*
* @param string $file
* @param int $quality
*
* @return $this
*/
public function saveWebp($file, $quality);

/**
* Save the image as a jpeg.
*
* @param string $file
* @param int $quality
*
* @return $this
*/
public function saveJpeg($file, $quality);

/**
* Works as resize() excepts that the layout will be cropped.
*
* @param int $width the width
* @param int $height the height
* @param int $background the background
* @param int|null $width the width
* @param int|null $height the height
* @param string|int $background the background
*
* @return $this
*/
Expand All @@ -105,9 +115,9 @@ public function cropResize($width = null, $height = null, $background = 0xffffff
/**
* Resize the image preserving scale. Can enlarge it.
*
* @param int $width the width
* @param int $height the height
* @param int $background the background
* @param int|null $width the width
* @param int|null $height the height
* @param string|int $background the background
* @param bool $crop
*
* @return $this
Expand All @@ -117,9 +127,9 @@ public function scaleResize($width = null, $height = null, $background = 0xfffff
/**
* Resizes the image. It will never be enlarged.
*
* @param int $width the width
* @param int $height the height
* @param int $background the background
* @param int|null $width the width
* @param int|null $height the height
* @param string|int $background the background
* @param bool $force
* @param bool $rescale
* @param bool $crop
Expand Down Expand Up @@ -151,9 +161,9 @@ public function enableProgressive();
* Resizes the image forcing the destination to have exactly the
* given width and the height.
*
* @param int $width the width
* @param int $height the height
* @param int $background the background
* @param int|null $width the width
* @param int|null $height the height
* @param string|int $background the background
*
* @return $this
*/
Expand All @@ -164,7 +174,7 @@ public function forceResize($width = null, $height = null, $background = 0xfffff
*
* @param int $width Desired width
* @param int $height Desired height
* @param int $background
* @param string|int $background
*
* @return $this
*/
Expand All @@ -173,7 +183,7 @@ public function zoomCrop($width, $height, $background = 0xffffff);
/**
* Fills the image background to $bg if the image is transparent.
*
* @param int $background background color
* @param string|int $background background color
*
* @return $this
*/
Expand Down Expand Up @@ -265,8 +275,8 @@ public function sepia();
* @param Image $other
* @param int $x
* @param int $y
* @param int $width
* @param int $height
* @param int|null $width
* @param int|null $height
*
* @return $this
*/
Expand All @@ -276,7 +286,7 @@ public function merge(Image $other, $x = 0, $y = 0, $width = null, $height = nul
* Rotate the image.
*
* @param float $angle
* @param int $background
* @param string|int $background
*
* @return $this
*/
Expand Down
Loading

0 comments on commit 70afaa7

Please sign in to comment.