diff --git a/src/Collection.php b/src/Collection.php index 5c218f22..c82fe7f0 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -117,6 +117,11 @@ class Collection implements CollectionInterface, IteratorAggregate, Countable return $positions[$key]; } + /** + * {@inheritdoc} + * + * @see CollectionInterface::get() + */ public function get(int|string $query, $default = null): mixed { if ($this->count() == 0) { diff --git a/src/Drivers/Imagick/Core.php b/src/Drivers/Imagick/Core.php index 74c41668..640ca688 100644 --- a/src/Drivers/Imagick/Core.php +++ b/src/Drivers/Imagick/Core.php @@ -2,6 +2,7 @@ namespace Intervention\Image\Drivers\Imagick; +use Collectable; use Imagick; use ImagickException; use Iterator; @@ -209,16 +210,42 @@ class Core implements CoreInterface, Iterator return $this; } + /** + * {@inheritdoc} + * + * @see CollectionInterface::first() + */ public function first(): FrameInterface { return $this->frame(0); } + /** + * {@inheritdoc} + * + * @see CollectableInterface::last() + */ public function last(): FrameInterface { return $this->frame($this->count() - 1); } + /** + * {@inheritdoc} + * + * @see CollectionInterface::toArray() + */ + public function toArray(): array + { + $frames = []; + + foreach ($this as $frame) { + $frames[] = $frame; + } + + return $frames; + } + public function __clone(): void { $this->imagick = clone $this->imagick; diff --git a/src/Interfaces/CollectionInterface.php b/src/Interfaces/CollectionInterface.php index 7a8d5c3c..2a7fc92e 100644 --- a/src/Interfaces/CollectionInterface.php +++ b/src/Interfaces/CollectionInterface.php @@ -68,6 +68,13 @@ interface CollectionInterface extends Traversable */ public function empty(): CollectionInterface; + /** + * Transform collection as array + * + * @return array + */ + public function toArray(): array; + /** * Extract items based on given values and discard the rest. *