1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-29 08:40:33 +02:00

Add doc blocks

This commit is contained in:
Oliver Vogel
2024-01-16 09:40:13 +01:00
parent 297eb5c3c4
commit 8fe96fff77
2 changed files with 116 additions and 1 deletions

View File

@@ -11,6 +11,11 @@ class Core extends Collection implements CoreInterface
{
protected int $loops = 0;
/**
* {@inheritdoc}
*
* @see CoreInterface::add()
*/
public function add(FrameInterface $frame): CoreInterface
{
$this->push($frame);
@@ -18,11 +23,21 @@ class Core extends Collection implements CoreInterface
return $this;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::native()
*/
public function native(): mixed
{
return $this->first()->native();
}
/**
* {@inheritdoc}
*
* @see CoreInterface::setNative()
*/
public function setNative(mixed $native): self
{
$this->empty()->push(new Frame($native));
@@ -30,6 +45,11 @@ class Core extends Collection implements CoreInterface
return $this;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::frame()
*/
public function frame(int $position): FrameInterface
{
$frame = $this->getAtPosition($position);
@@ -41,11 +61,21 @@ class Core extends Collection implements CoreInterface
return $frame;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::loops()
*/
public function loops(): int
{
return $this->loops;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::setLoops()
*/
public function setLoops(int $loops): self
{
$this->loops = $loops;
@@ -53,16 +83,31 @@ class Core extends Collection implements CoreInterface
return $this;
}
/**
* {@inheritdoc}
*
* @see CollectionInterface::first()
*/
public function first(): FrameInterface
{
return parent::first();
}
/**
* {@inheritdoc}
*
* @see CollectionInterface::last()
*/
public function last(): FrameInterface
{
return parent::last();
}
/**
* Clone instance
*
* @return void
*/
public function __clone(): void
{
foreach ($this->items as $key => $frame) {

View File

@@ -2,7 +2,6 @@
namespace Intervention\Image\Drivers\Imagick;
use Collectable;
use Imagick;
use ImagickException;
use Iterator;
@@ -16,6 +15,12 @@ class Core implements CoreInterface, Iterator
{
protected int $iteratorIndex = 0;
/**
* Create new core instance
*
* @param Imagick $imagick
* @return void
*/
public function __construct(protected Imagick $imagick)
{
}
@@ -116,6 +121,11 @@ class Core implements CoreInterface, Iterator
return $this;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::add()
*/
public function add(FrameInterface $frame): CoreInterface
{
$imagick = $frame->native();
@@ -136,11 +146,21 @@ class Core implements CoreInterface, Iterator
return $this;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::count()
*/
public function count(): int
{
return $this->imagick->getNumberImages();
}
/**
* {@inheritdoc}
*
* @see Interator::rewind()
*/
public function current(): mixed
{
$this->imagick->setIteratorIndex($this->iteratorIndex);
@@ -148,16 +168,31 @@ class Core implements CoreInterface, Iterator
return new Frame($this->imagick->current());
}
/**
* {@inheritdoc}
*
* @see Interator::rewind()
*/
public function next(): void
{
$this->iteratorIndex = $this->iteratorIndex + 1;
}
/**
* {@inheritdoc}
*
* @see Interator::rewind()
*/
public function key(): mixed
{
return $this->iteratorIndex;
}
/**
* {@inheritdoc}
*
* @see Interator::rewind()
*/
public function valid(): bool
{
try {
@@ -169,16 +204,31 @@ class Core implements CoreInterface, Iterator
return $result;
}
/**
* {@inheritdoc}
*
* @see Interator::rewind()
*/
public function rewind(): void
{
$this->iteratorIndex = 0;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::native()
*/
public function native(): mixed
{
return $this->imagick;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::setNative()
*/
public function setNative(mixed $native): CoreInterface
{
$this->imagick = $native;
@@ -186,6 +236,11 @@ class Core implements CoreInterface, Iterator
return $this;
}
/**
* {@inheritdoc}
*
* @see CoreInterface::frame()
*/
public function frame(int $position): FrameInterface
{
foreach ($this->imagick as $core) {
@@ -197,11 +252,21 @@ class Core implements CoreInterface, Iterator
throw new AnimationException('Frame #' . $position . ' could not be found in the image.');
}
/**
* {@inheritdoc}
*
* @see CoreInterface::loops()
*/
public function loops(): int
{
return $this->imagick->getImageIterations();
}
/**
* {@inheritdoc}
*
* @see CoreInterface::setLoops()
*/
public function setLoops(int $loops): CoreInterface
{
$this->imagick = $this->imagick->coalesceImages();
@@ -246,6 +311,11 @@ class Core implements CoreInterface, Iterator
return $frames;
}
/**
* Clone instance
*
* @return void
*/
public function __clone(): void
{
$this->imagick = clone $this->imagick;