mirror of
https://github.com/Intervention/image.git
synced 2025-01-29 09:47:36 +01:00
Add method to CollectionInterface
This commit is contained in:
parent
ede244d252
commit
297eb5c3c4
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user