mirror of
https://github.com/Intervention/image.git
synced 2025-08-11 16:34:00 +02:00
Remove Collection::pushEach()
This commit is contained in:
@@ -177,19 +177,6 @@ class Collection implements CollectionInterface, IteratorAggregate, Countable
|
||||
return new self($items);
|
||||
}
|
||||
|
||||
public function pushEach(array $data, ?callable $callback = null): CollectionInterface
|
||||
{
|
||||
if (! is_iterable($data)) {
|
||||
throw new RuntimeException('Unable to iterate given data.');
|
||||
}
|
||||
|
||||
foreach ($data as $item) {
|
||||
$this->push(is_callable($callback) ? $callback($item) : $item);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
|
@@ -76,17 +76,6 @@ class CollectionTest extends TestCase
|
||||
$this->assertInstanceOf(Collection::class, $result);
|
||||
}
|
||||
|
||||
public function testPushEach()
|
||||
{
|
||||
$collection = Collection::create()->pushEach(['foo', 'bar', 'baz'], function ($item) {
|
||||
return strtoupper($item);
|
||||
});
|
||||
$this->assertEquals(3, $collection->count());
|
||||
$this->assertEquals('FOO', $collection->get(0));
|
||||
$this->assertEquals('BAR', $collection->get(1));
|
||||
$this->assertEquals('BAZ', $collection->get(2));
|
||||
}
|
||||
|
||||
public function testToArray()
|
||||
{
|
||||
$collection = new Collection(['foo', 'bar', 'baz']);
|
||||
@@ -137,6 +126,16 @@ class CollectionTest extends TestCase
|
||||
$this->assertEquals(['example' => 'value'], $collection->get('baz.test3'));
|
||||
}
|
||||
|
||||
public function testGetAtPosition(): void
|
||||
{
|
||||
$collection = new Collection([1, 2, 'foo' => 'bar']);
|
||||
$this->assertEquals(1, $collection->getAtPosition(0));
|
||||
$this->assertEquals(2, $collection->getAtPosition(1));
|
||||
$this->assertEquals('bar', $collection->getAtPosition(2));
|
||||
$this->assertNull($collection->getAtPosition(3));
|
||||
$this->assertEquals('default', $collection->getAtPosition(3, 'default'));
|
||||
}
|
||||
|
||||
public function testEmpty(): void
|
||||
{
|
||||
$collection = new Collection([1, 2, 3]);
|
||||
|
Reference in New Issue
Block a user