mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 09:31:53 +02:00
Throw exception on exceeding frame count
This commit is contained in:
@@ -7,6 +7,7 @@ use ImagickException;
|
||||
use Iterator;
|
||||
use Intervention\Image\Interfaces\CoreInterface;
|
||||
use Intervention\Image\Exceptions\AnimationException;
|
||||
use Intervention\Image\Exceptions\RuntimeException;
|
||||
use Intervention\Image\Interfaces\CollectionInterface;
|
||||
use Intervention\Image\Interfaces\FrameInterface;
|
||||
|
||||
@@ -89,6 +90,10 @@ class Core implements CoreInterface, Iterator
|
||||
*/
|
||||
public function slice(int $offset, ?int $length = null): CollectionInterface
|
||||
{
|
||||
if ($offset >= $this->count()) {
|
||||
throw new RuntimeException('Offset exceeds the maximum value.');
|
||||
}
|
||||
|
||||
$allowed_indexes = [];
|
||||
$length = is_null($length) ? $this->count() : $length;
|
||||
for ($i = $offset; $i < $offset + $length; $i++) {
|
||||
|
Reference in New Issue
Block a user