1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-03 02:42:45 +02:00

Add doc blocks

This commit is contained in:
Oliver Vogel
2023-11-26 15:33:31 +01:00
parent b95d9033ab
commit 6d333c8fd6
3 changed files with 453 additions and 5 deletions

View File

@@ -72,181 +72,361 @@ final class Image implements ImageInterface, Countable
) { ) {
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::driver()
*/
public function driver(): DriverInterface public function driver(): DriverInterface
{ {
return $this->driver; return $this->driver;
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::core()
*/
public function core(): CoreInterface public function core(): CoreInterface
{ {
return $this->core; return $this->core;
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::count()
*/
public function count(): int public function count(): int
{ {
return $this->core->count(); return $this->core->count();
} }
/**
* Implementation of IteratorAggregate
*
* @return Traversable
*/
public function getIterator(): Traversable public function getIterator(): Traversable
{ {
return $this->core; return $this->core;
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::isAnimated()
*/
public function isAnimated(): bool public function isAnimated(): bool
{ {
return $this->count() > 1; return $this->count() > 1;
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::removeAnimation(
*/
public function removeAnimation(int|string $position = 0): ImageInterface public function removeAnimation(int|string $position = 0): ImageInterface
{ {
return $this->modify(new RemoveAnimationModifier($position)); return $this->modify(new RemoveAnimationModifier($position));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::loops()
*/
public function loops(): int public function loops(): int
{ {
return $this->core->loops(); return $this->core->loops();
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::exif()
*/
public function exif(?string $query = null): mixed public function exif(?string $query = null): mixed
{ {
return is_null($query) ? $this->exif : $this->exif->get($query); return is_null($query) ? $this->exif : $this->exif->get($query);
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::modify()
*/
public function modify(ModifierInterface $modifier): ImageInterface public function modify(ModifierInterface $modifier): ImageInterface
{ {
return $this->driver->resolve($modifier)->apply($this); return $this->driver->resolve($modifier)->apply($this);
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::analyze()
*/
public function analyze(AnalyzerInterface $analyzer): mixed public function analyze(AnalyzerInterface $analyzer): mixed
{ {
return $this->driver->resolve($analyzer)->analyze($this); return $this->driver->resolve($analyzer)->analyze($this);
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::encode()
*/
public function encode(EncoderInterface $encoder): EncodedImage public function encode(EncoderInterface $encoder): EncodedImage
{ {
return $this->driver->resolve($encoder)->encode($this); return $this->driver->resolve($encoder)->encode($this);
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::width()
*/
public function width(): int public function width(): int
{ {
return $this->analyze(new WidthAnalyzer()); return $this->analyze(new WidthAnalyzer());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::height()
*/
public function height(): int public function height(): int
{ {
return $this->analyze(new HeightAnalyzer()); return $this->analyze(new HeightAnalyzer());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::size()
*/
public function size(): SizeInterface public function size(): SizeInterface
{ {
return new Rectangle($this->width(), $this->height()); return new Rectangle($this->width(), $this->height());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::colorspace()
*/
public function colorspace(): ColorspaceInterface public function colorspace(): ColorspaceInterface
{ {
return $this->analyze(new ColorspaceAnalyzer()); return $this->analyze(new ColorspaceAnalyzer());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::setColorspace()
*/
public function setColorspace(string|ColorspaceInterface $colorspace): ImageInterface public function setColorspace(string|ColorspaceInterface $colorspace): ImageInterface
{ {
return $this->modify(new ColorspaceModifier($colorspace)); return $this->modify(new ColorspaceModifier($colorspace));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::resolution()
*/
public function resolution(): ResolutionInterface public function resolution(): ResolutionInterface
{ {
return $this->analyze(new ResolutionAnalyzer()); return $this->analyze(new ResolutionAnalyzer());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::setResolution()
*/
public function setResolution(float $x, float $y): ImageInterface public function setResolution(float $x, float $y): ImageInterface
{ {
return $this->modify(new ResolutionModifier($x, $y)); return $this->modify(new ResolutionModifier($x, $y));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::pickColor()
*/
public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface
{ {
return $this->analyze(new PixelColorAnalyzer($x, $y, $frame_key)); return $this->analyze(new PixelColorAnalyzer($x, $y, $frame_key));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::pickColors()
*/
public function pickColors(int $x, int $y): CollectionInterface public function pickColors(int $x, int $y): CollectionInterface
{ {
return $this->analyze(new PixelColorsAnalyzer($x, $y)); return $this->analyze(new PixelColorsAnalyzer($x, $y));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::profile()
*/
public function profile(): ProfileInterface public function profile(): ProfileInterface
{ {
return $this->analyze(new ProfileAnalyzer()); return $this->analyze(new ProfileAnalyzer());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::setProfile()
*/
public function setProfile(ProfileInterface $profile): ImageInterface public function setProfile(ProfileInterface $profile): ImageInterface
{ {
return $this->modify(new ProfileModifier($profile)); return $this->modify(new ProfileModifier($profile));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::removeProfile()
*/
public function removeProfile(): ImageInterface public function removeProfile(): ImageInterface
{ {
return $this->modify(new ProfileRemovalModifier()); return $this->modify(new ProfileRemovalModifier());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::sharpen()
*/
public function sharpen(int $amount = 10): ImageInterface public function sharpen(int $amount = 10): ImageInterface
{ {
return $this->modify(new SharpenModifier($amount)); return $this->modify(new SharpenModifier($amount));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::invert()
*/
public function invert(): ImageInterface public function invert(): ImageInterface
{ {
return $this->modify(new InvertModifier()); return $this->modify(new InvertModifier());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::pixelate()
*/
public function pixelate(int $size): ImageInterface public function pixelate(int $size): ImageInterface
{ {
return $this->modify(new PixelateModifier($size)); return $this->modify(new PixelateModifier($size));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::greyscale()
*/
public function greyscale(): ImageInterface public function greyscale(): ImageInterface
{ {
return $this->modify(new GreyscaleModifier()); return $this->modify(new GreyscaleModifier());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::brightness()
*/
public function brightness(int $level): ImageInterface public function brightness(int $level): ImageInterface
{ {
return $this->modify(new BrightnessModifier($level)); return $this->modify(new BrightnessModifier($level));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::contrast()
*/
public function contrast(int $level): ImageInterface public function contrast(int $level): ImageInterface
{ {
return $this->modify(new ContrastModifier($level)); return $this->modify(new ContrastModifier($level));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::gamma()
*/
public function gamma(float $gamma): ImageInterface public function gamma(float $gamma): ImageInterface
{ {
return $this->modify(new GammaModifier($gamma)); return $this->modify(new GammaModifier($gamma));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::colorize()
*/
public function colorize(int $red = 0, int $green = 0, int $blue = 0): ImageInterface public function colorize(int $red = 0, int $green = 0, int $blue = 0): ImageInterface
{ {
return $this->modify(new ColorizeModifier($red, $green, $blue)); return $this->modify(new ColorizeModifier($red, $green, $blue));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::flip()
*/
public function flip(): ImageInterface public function flip(): ImageInterface
{ {
return $this->modify(new FlipModifier()); return $this->modify(new FlipModifier());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::flop()
*/
public function flop(): ImageInterface public function flop(): ImageInterface
{ {
return $this->modify(new FlopModifier()); return $this->modify(new FlopModifier());
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::blur()
*/
public function blur(int $amount = 5): ImageInterface public function blur(int $amount = 5): ImageInterface
{ {
return $this->modify(new BlurModifier($amount)); return $this->modify(new BlurModifier($amount));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::rotate()
*/
public function rotate(float $angle, mixed $background = 'ffffff'): ImageInterface public function rotate(float $angle, mixed $background = 'ffffff'): ImageInterface
{ {
return $this->modify(new RotateModifier($angle, $background)); return $this->modify(new RotateModifier($angle, $background));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::text()
*/
public function text(string $text, int $x, int $y, callable|FontInterface $font): ImageInterface public function text(string $text, int $x, int $y, callable|FontInterface $font): ImageInterface
{ {
return $this->modify( return $this->modify(
@@ -258,41 +438,71 @@ final class Image implements ImageInterface, Countable
); );
} }
public function toJpeg(int $quality = 75): EncodedImageInterface /**
{ * {@inheritdoc}
return $this->encode(new JpegEncoder($quality)); *
} * @see ImageInterface::resize()
*/
public function resize(?int $width = null, ?int $height = null): ImageInterface public function resize(?int $width = null, ?int $height = null): ImageInterface
{ {
return $this->modify(new ResizeModifier($width, $height)); return $this->modify(new ResizeModifier($width, $height));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::resizeDown()
*/
public function resizeDown(?int $width = null, ?int $height = null): ImageInterface public function resizeDown(?int $width = null, ?int $height = null): ImageInterface
{ {
return $this->modify(new ResizeDownModifier($width, $height)); return $this->modify(new ResizeDownModifier($width, $height));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::scale()
*/
public function scale(?int $width = null, ?int $height = null): ImageInterface public function scale(?int $width = null, ?int $height = null): ImageInterface
{ {
return $this->modify(new ScaleModifier($width, $height)); return $this->modify(new ScaleModifier($width, $height));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::scaleDown()
*/
public function scaleDown(?int $width = null, ?int $height = null): ImageInterface public function scaleDown(?int $width = null, ?int $height = null): ImageInterface
{ {
return $this->modify(new ScaleDownModifier($width, $height)); return $this->modify(new ScaleDownModifier($width, $height));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::fit()
*/
public function fit(int $width, int $height, string $position = 'center'): ImageInterface public function fit(int $width, int $height, string $position = 'center'): ImageInterface
{ {
return $this->modify(new FitModifier($width, $height, $position)); return $this->modify(new FitModifier($width, $height, $position));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::fitDown()
*/
public function fitDown(int $width, int $height, string $position = 'center'): ImageInterface public function fitDown(int $width, int $height, string $position = 'center'): ImageInterface
{ {
return $this->modify(new FitDownModifier($width, $height, $position)); return $this->modify(new FitDownModifier($width, $height, $position));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::pad()
*/
public function pad( public function pad(
int $width, int $width,
int $height, int $height,
@@ -302,6 +512,11 @@ final class Image implements ImageInterface, Countable
return $this->modify(new PadModifier($width, $height, $background, $position)); return $this->modify(new PadModifier($width, $height, $background, $position));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::padDown()
*/
public function padDown( public function padDown(
int $width, int $width,
int $height, int $height,
@@ -311,6 +526,11 @@ final class Image implements ImageInterface, Countable
return $this->modify(new PadModifier($width, $height, $background, $position)); return $this->modify(new PadModifier($width, $height, $background, $position));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::crop()
*/
public function crop( public function crop(
int $width, int $width,
int $height, int $height,
@@ -321,6 +541,11 @@ final class Image implements ImageInterface, Countable
return $this->modify(new CropModifier($width, $height, $offset_x, $offset_y, $position)); return $this->modify(new CropModifier($width, $height, $offset_x, $offset_y, $position));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::place()
*/
public function place( public function place(
mixed $element, mixed $element,
string $position = 'top-left', string $position = 'top-left',
@@ -330,41 +555,93 @@ final class Image implements ImageInterface, Countable
return $this->modify(new PlaceModifier($element, $position, $offset_x, $offset_y)); return $this->modify(new PlaceModifier($element, $position, $offset_x, $offset_y));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::fill()
*/
public function fill(mixed $color, ?int $x = null, ?int $y = null): ImageInterface public function fill(mixed $color, ?int $x = null, ?int $y = null): ImageInterface
{ {
return $this->modify(new FillModifier($color, new Point($x, $y))); return $this->modify(new FillModifier($color, new Point($x, $y)));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::toJpeg()
*/
public function toJpeg(int $quality = 75): EncodedImageInterface
{
return $this->encode(new JpegEncoder($quality));
}
/**
* Alias of self::toJpeg()
*
* @param int $quality
* @return EncodedImageInterface
*/
public function toJpg(int $quality = 75): EncodedImageInterface public function toJpg(int $quality = 75): EncodedImageInterface
{ {
return $this->toJpeg($quality); return $this->toJpeg($quality);
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::toPng()
*/
public function toPng(int $color_limit = 0): EncodedImageInterface public function toPng(int $color_limit = 0): EncodedImageInterface
{ {
return $this->encode(new PngEncoder($color_limit)); return $this->encode(new PngEncoder($color_limit));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::toGif()
*/
public function toGif(int $color_limit = 0): EncodedImageInterface public function toGif(int $color_limit = 0): EncodedImageInterface
{ {
return $this->encode(new GifEncoder($color_limit)); return $this->encode(new GifEncoder($color_limit));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::toWebp()
*/
public function toWebp(int $quality = 75): EncodedImageInterface public function toWebp(int $quality = 75): EncodedImageInterface
{ {
return $this->encode(new WebpEncoder($quality)); return $this->encode(new WebpEncoder($quality));
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::toBitmap()
*/
public function toBitmap(int $color_limit = 0): EncodedImageInterface public function toBitmap(int $color_limit = 0): EncodedImageInterface
{ {
return $this->encode(new BmpEncoder($color_limit)); return $this->encode(new BmpEncoder($color_limit));
} }
/**
* Alias if self::toBitmap()
*
* @param int $color_limit
* @return EncodedImageInterface
*/
public function toBmp(int $color_limit = 0): EncodedImageInterface public function toBmp(int $color_limit = 0): EncodedImageInterface
{ {
return $this->toBitmap($color_limit); return $this->toBitmap($color_limit);
} }
/**
* {@inheritdoc}
*
* @see ImageInterface::toAvif()
*/
public function toAvif(int $quality = 75): EncodedImageInterface public function toAvif(int $quality = 75): EncodedImageInterface
{ {
return $this->encode(new AvifEncoder($quality)); return $this->encode(new AvifEncoder($quality));

View File

@@ -4,19 +4,115 @@ namespace Intervention\Image\Interfaces;
interface FontInterface interface FontInterface
{ {
/**
* Set color of font
*
* @param mixed $color
* @return FontInterface
*/
public function setColor(mixed $color): self; public function setColor(mixed $color): self;
/**
* Get color of font
*
* @return mixed
*/
public function color(): mixed; public function color(): mixed;
/**
* Set font size
*
* @param float $size
* @return FontInterface
*/
public function setSize(float $size): self; public function setSize(float $size): self;
/**
* Get font size
*
* @return float
*/
public function size(): float; public function size(): float;
/**
* Set rotation angle of font
*
* @param float $angle
* @return FontInterface
*/
public function setAngle(float $angle): self; public function setAngle(float $angle): self;
/**
* Get rotation angle of font
*
* @return float
*/
public function angle(): float; public function angle(): float;
/**
* Set font filename
*
* @param string $filename
* @return FontInterface
*/
public function setFilename(string $filename): self; public function setFilename(string $filename): self;
/**
* Get font filename
*
* @return null|string
*/
public function filename(): ?string; public function filename(): ?string;
/**
* Determine if font has a corresponding filename
*
* @return bool
*/
public function hasFilename(): bool; public function hasFilename(): bool;
/**
* Set horizontal alignment of font
*
* @param string $align
* @return FontInterface
*/
public function setAlignment(string $align): self; public function setAlignment(string $align): self;
/**
* Get horizontal alignment of font
*
* @return string
*/
public function alignment(): string; public function alignment(): string;
/**
* Set vertical alignment of font
*
* @param string $align
* @return FontInterface
*/
public function setValignment(string $align): self; public function setValignment(string $align): self;
/**
* Get vertical alignment of font
*
* @return string
*/
public function valignment(): string; public function valignment(): string;
/**
* Set typographical line height
*
* @param float $value
* @return FontInterface
*/
public function setLineHeight(float $value): self; public function setLineHeight(float $value): self;
/**
* Get line height of font
*
* @return float
*/
public function lineHeight(): float; public function lineHeight(): float;
} }

View File

@@ -19,6 +19,11 @@ class Font implements FontInterface
$this->filename = $filename; $this->filename = $filename;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::setSize()
*/
public function setSize(float $size): FontInterface public function setSize(float $size): FontInterface
{ {
$this->size = $size; $this->size = $size;
@@ -26,11 +31,21 @@ class Font implements FontInterface
return $this; return $this;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::size()
*/
public function size(): float public function size(): float
{ {
return $this->size; return $this->size;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::setAngle()
*/
public function setAngle(float $angle): FontInterface public function setAngle(float $angle): FontInterface
{ {
$this->angle = $angle; $this->angle = $angle;
@@ -38,11 +53,21 @@ class Font implements FontInterface
return $this; return $this;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::angle()
*/
public function angle(): float public function angle(): float
{ {
return $this->angle; return $this->angle;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::setFilename()
*/
public function setFilename(string $filename): FontInterface public function setFilename(string $filename): FontInterface
{ {
$this->filename = $filename; $this->filename = $filename;
@@ -50,16 +75,31 @@ class Font implements FontInterface
return $this; return $this;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::filename()
*/
public function filename(): ?string public function filename(): ?string
{ {
return $this->filename; return $this->filename;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::hasFilename()
*/
public function hasFilename(): bool public function hasFilename(): bool
{ {
return !is_null($this->filename) && is_file($this->filename); return !is_null($this->filename) && is_file($this->filename);
} }
/**
* {@inheritdoc}
*
* @see FontInterface::setColor()
*/
public function setColor(mixed $color): FontInterface public function setColor(mixed $color): FontInterface
{ {
$this->color = $color; $this->color = $color;
@@ -67,16 +107,31 @@ class Font implements FontInterface
return $this; return $this;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::color()
*/
public function color(): mixed public function color(): mixed
{ {
return $this->color; return $this->color;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::alignment()
*/
public function alignment(): string public function alignment(): string
{ {
return $this->alignment; return $this->alignment;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::setAlignment()
*/
public function setAlignment(string $value): FontInterface public function setAlignment(string $value): FontInterface
{ {
$this->alignment = $value; $this->alignment = $value;
@@ -84,11 +139,21 @@ class Font implements FontInterface
return $this; return $this;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::valignment()
*/
public function valignment(): string public function valignment(): string
{ {
return $this->valignment; return $this->valignment;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::setValignment()
*/
public function setValignment(string $value): FontInterface public function setValignment(string $value): FontInterface
{ {
$this->valignment = $value; $this->valignment = $value;
@@ -96,6 +161,11 @@ class Font implements FontInterface
return $this; return $this;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::setLineHeight()
*/
public function setLineHeight(float $height): FontInterface public function setLineHeight(float $height): FontInterface
{ {
$this->lineHeight = $height; $this->lineHeight = $height;
@@ -103,6 +173,11 @@ class Font implements FontInterface
return $this; return $this;
} }
/**
* {@inheritdoc}
*
* @see FontInterface::lineHeight()
*/
public function lineHeight(): float public function lineHeight(): float
{ {
return $this->lineHeight; return $this->lineHeight;