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