1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-01 01:51:43 +02:00

Add doc blocks

This commit is contained in:
Oliver Vogel
2023-11-26 16:44:38 +01:00
parent d59614578f
commit 8a698b6e60

View File

@@ -16,36 +16,85 @@ final class ImageManager
$this->driver = $this->resolveDriver($driver); $this->driver = $this->resolveDriver($driver);
} }
/**
* Create image mangager with given driver
*
* @param string|DriverInterface $driver
* @return ImageManager
*/
public static function withDriver(string|DriverInterface $driver): self public static function withDriver(string|DriverInterface $driver): self
{ {
return new self(self::resolveDriver($driver)); return new self(self::resolveDriver($driver));
} }
/**
* Create image manager with GD driver
*
* @return ImageManager
*/
public static function gd(): self public static function gd(): self
{ {
return self::withDriver(GdDriver::class); return self::withDriver(GdDriver::class);
} }
/**
* Create image manager with Imagick driver
*
* @return ImageManager
*/
public static function imagick(): self public static function imagick(): self
{ {
return self::withDriver(ImagickDriver::class); return self::withDriver(ImagickDriver::class);
} }
/**
* Create new image instance with given width & height
*
* @param int $width
* @param int $height
* @return ImageInterface
*/
public function create(int $width, int $height): ImageInterface public function create(int $width, int $height): ImageInterface
{ {
return $this->driver->createImage($width, $height); return $this->driver->createImage($width, $height);
} }
/**
* Create new image instance from given source which can be one of the following
*
* - Path in filesystem
* - File Pointer resource
* - SplFileInfo object
* - Raw binary image data
* - Base64 encoded image data
* - Data Uri
* - Intervention Image Instance
*
* @param mixed $input
* @return ImageInterface
*/
public function read(mixed $input): ImageInterface public function read(mixed $input): ImageInterface
{ {
return $this->driver->handleInput($input); return $this->driver->handleInput($input);
} }
/**
* Create new animated image by given callback
*
* @param callable $init
* @return ImageInterface
*/
public function animate(callable $init): ImageInterface public function animate(callable $init): ImageInterface
{ {
return $this->driver->createAnimation($init); return $this->driver->createAnimation($init);
} }
/**
* Return driver object
*
* @param string|DriverInterface $driver
* @return DriverInterface
*/
private static function resolveDriver(string|DriverInterface $driver): DriverInterface private static function resolveDriver(string|DriverInterface $driver): DriverInterface
{ {
if (is_object($driver)) { if (is_object($driver)) {