FOF30\Utils\Collection::splice PHP Метод

splice() публичный Метод

Splice portion of the underlying collection array.
public splice ( integer $offset, integer $length, mixed $replacement = [] ) : Collection
$offset integer
$length integer
$replacement mixed
Результат Collection
    public function splice($offset, $length = 0, $replacement = array())
    {
        return new static(array_splice($this->items, $offset, $length, $replacement));
    }

Usage Example

Пример #1
0
 public function testSplice()
 {
     $data = new Collection(array('foo', 'baz'));
     $data->splice(1, 0, 'bar');
     $this->assertEquals(array('foo', 'bar', 'baz'), $data->all());
     $data = new Collection(array('foo', 'baz'));
     $data->splice(1, 1);
     $this->assertEquals(array('foo'), $data->all());
     $data = new Collection(array('foo', 'baz'));
     $cut = $data->splice(1, 1, 'bar');
     $this->assertEquals(array('foo', 'bar'), $data->all());
     $this->assertEquals(array('baz'), $cut->all());
 }